ID: 40065 Updated by: [EMAIL PROTECTED] Reported By: ugo at iliona dot net -Status: Open +Status: Bogus Bug Type: Arrays related Operating System: Linux/BSD PHP Version: 5.2.0 New Comment:
Please do not submit the same bug more than once. An existing bug report already describes this very problem. Even if you feel that your issue is somewhat different, the resolution is likely to be the same. Thank you for your interest in PHP. , Previous Comments: ------------------------------------------------------------------------ [2007-01-08 17:42:34] ugo at iliona dot net Description: ------------ Hello, This bug was tried on multiple Unix versions and multiple processors (32/64bits), and multiple PHP5 versions (including 5.2.0), so it seems really to be on the side of PHP. After using a foreach with a referenced value, and then another foreach (without the referenced value), the original array is broken. Apparently, the last value of the array takes the value of the n - 1 last value. I've reduced the problem to its simplest form and attached it to this bug report. Greeting, Ugo PARSI Reproduce code: --------------- <?php $arr = array(1, 2, 3, 4); foreach ($arr as &$value) { $value = $value * 2; } print_r($arr); foreach ($arr as $value) { $value = $value; } print_r($arr); ?> Expected result: ---------------- Array ( [0] => 2 [1] => 4 [2] => 6 [3] => 8 ) Array ( [0] => 2 [1] => 4 [2] => 6 [3] => 8 ) Actual result: -------------- Array ( [0] => 2 [1] => 4 [2] => 6 [3] => 8 ) Array ( [0] => 2 [1] => 4 [2] => 6 [3] => 6 ) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=40065&edit=1