From: oliver at teqneers dot de
Operating system: Suse 9.0
PHP version: 4.3.8
PHP Bug Type: Arrays related
Bug description: unset deletes array entries and its copied entries
Description:
------------
When I copy an array with a normal "=" the copy is not a real copy, but a
reference to it. This only seems to happen to cascaded arrays.
When an entry of the original array is unset, the copied entry will be
unset as well.
Reproduce code:
---------------
$arr = array( 'in' => array(1,2,3) );
$copy = $arr;
print_r($copy);
unset( $arr['in'][1] );
print_r($copy);
Expected result:
----------------
Array
(
[in] => Array
(
[0] => 1
[1] => 2
[2] => 3
)
)
Array
(
[in] => Array
(
[0] => 1
[1] => 2
[2] => 3
)
)
Actual result:
--------------
Array
(
[in] => Array
(
[0] => 1
[1] => 2
[2] => 3
)
)
Array
(
[in] => Array
(
[0] => 1
[2] => 3
)
)
--
Edit bug report at http://bugs.php.net/?id=30179&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=30179&r=trysnapshot4
Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=30179&r=trysnapshot50
Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=30179&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=30179&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=30179&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=30179&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=30179&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=30179&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=30179&r=support
Expected behavior: http://bugs.php.net/fix.php?id=30179&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=30179&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=30179&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=30179&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=30179&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=30179&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=30179&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=30179&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=30179&r=float
MySQL Configuration Error: http://bugs.php.net/fix.php?id=30179&r=mysqlcfg