ID: 39307
Updated by: [EMAIL PROTECTED]
Reported By: lolitka at gmail dot com
-Status: Open
+Status: Bogus
Bug Type: Unknown/Other Function
Operating System: Windows XP
PHP Version: 5.1.6
New Comment:
Expected behaviour.
You're using the same variable in foreach-by-ref and then in foreach
again, when it still points to the last element of the array.
Change $line to something else in the second foreach() and it's gone.
Previous Comments:
------------------------------------------------------------------------
[2006-10-30 14:19:59] lolitka at gmail dot com
Description:
------------
RUN this and see the output .... prety serious BUG i think
Reproduce code:
---------------
<?
$lines[0]="a;1";
$lines[1]="b;1";
$lines[2]="c;1";
$lines[3]="d;1";
print_r($lines);
foreach ($lines as $line_num => &$line) {
$cell = explode(";", $line);
$cell[1] = str_replace('1', '2', $cell[1]);
$line = implode (";", $cell);
}
print_r($lines);
echo ("<br/>");
foreach ($lines as $line_num => $line) {
echo $line_num." = ".$line."<hr>";
}
?>
Expected result:
----------------
last line shloud be last line ...
Actual result:
--------------
last line is taken from line before previous line
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=39307&edit=1