#30179 [Opn->Bgs]: unset deletes array entries and its copied entries
| From: | derick@php.net | Date: | Tue, 21 Sep 2004 22:04:44 +0000 |
| Subject: | #30179 [Opn->Bgs]: unset deletes array entries and its copied entries | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-66515@lists.php.net to get a copy of this message | ||
ID: 30179
Updated by: derick@php.net
Reported By: oliver at teqneers dot de
-Status: Open
+Status: Bogus
Bug Type: Arrays related
Operating System: Suse 9.0
PHP Version: 4.3.8
New Comment:
Works fine here with 4.3.6, 4.3.8, 4.3.9-dev, 5.0.1 and 5.1.0-dev.
Previous Comments:
------------------------------------------------------------------------
[2004-09-21 15:50:47] oliver at teqneers dot de
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 this bug report at http://bugs.php.net/?id=30179&edit=1