ID:               39114
 Updated by:       [EMAIL PROTECTED]
 Reported By:      perso at cyprien dot org
-Status:           Open
+Status:           Bogus
 Bug Type:         Arrays related
 Operating System: Debian stable
 PHP Version:      5.1.6
 New Comment:

Duplicate of bug #29992


Previous Comments:
------------------------------------------------------------------------

[2006-10-10 13:30:14] perso at cyprien dot org

Description:
------------
Foreach loop access original array when using references on a previous
loop.

Reproduce code:
---------------
<?php

$list = array( 1, 2, 3, 4 );

$new_list = array();

foreach( $list as $item ){
        $z =& $new_list[];
        $z = $item;
}

//unset( $z );

print_r( $new_list );

foreach( $new_list as $z ){
}

print_r( $new_list );



?>


Expected result:
----------------
Array
(
    [0] => 1
    [1] => 2
    [2] => 3
    [3] => 4
)
Array
(
    [0] => 1
    [1] => 2
    [2] => 3
    [3] => 4
)

Actual result:
--------------
Array
(
    [0] => 1
    [1] => 2
    [2] => 3
    [3] => 4
)
Array
(
    [0] => 1
    [1] => 2
    [2] => 3
    [3] => 3
)


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=39114&edit=1

Reply via email to