ID: 29992
User updated by: fletch at pobox dot com
-Summary: problem with foreach by reference
Reported By: fletch at pobox dot com
Status: Open
Bug Type: Zend Engine 2 problem
Operating System: linux
PHP Version: 5.0.1
New Comment:
changed the summary
Previous Comments:
------------------------------------------------------------------------
[2004-09-06 05:54:50] fletch at pobox dot com
Description:
------------
foreach with a reference seems to corrupt the last element in an array
Reproduce code:
---------------
<?php
$array = array(1,2,3);
foreach( $array as &$item ) { }
print_r( $array );
foreach( $array as $item ) { }
print_r( $array );
?>
Expected result:
----------------
Array
(
[0] => 1
[1] => 2
[2] => 3
)
Array
(
[0] => 1
[1] => 2
[2] => 3
)
Actual result:
--------------
Array
(
[0] => 1
[1] => 2
[2] => 3
)
Array
(
[0] => 1
[1] => 2
[2] => 2
)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=29992&edit=1