ID: 29687
Updated by: [EMAIL PROTECTED]
Reported By: jakub dot phpbug at horky dot net
-Status: Open
+Status: Verified
-Bug Type: Arrays related
+Bug Type: Zend Engine 2 problem
-Operating System: Windows Server 2003
+Operating System: *
-PHP Version: 5CVS-2004-08-15
+PHP Version: 5CVS-2005-03-07
Previous Comments:
------------------------------------------------------------------------
[2004-08-15 15:19:47] jakub dot phpbug at horky dot net
Description:
------------
A value passed inside foreach() costruct by reference does not reflect
the changes made to that value when the iterated array is touched by
some array function, like key() or current().
In example below, if you comment out the key() line, it will work OK.
I think that this bug is closely related to the bug #28939.
Reproduce code:
---------------
<?php
$array = array("NO", "NO", "NO");
foreach($array as $index => &$item)
{
key($array); // there may be also current(), reset(),
// first(), next(), prev(), foreach etc.
$item = "YES";
var_dump($item);
}
print_r($array);
?>
Expected result:
----------------
string(3) "YES"
string(3) "YES"
string(3) "YES"
Array
(
[0] => YES
[1] => YES
[2] => YES
)
Actual result:
--------------
string(3) "YES"
string(3) "YES"
string(3) "YES"
Array
(
[0] => YES
[1] => NO
[2] => NO
)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=29687&edit=1