ID: 47028 Updated by: [email protected] Reported By: kobieta dot ryba at gmail dot com -Status: Open +Status: Bogus Bug Type: Scripting Engine problem Operating System: Linux PHP Version: 6CVS-2009-01-07 (CVS) New Comment:
Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php You overwrite the variable you're looping through, no wonder the second iteration fails. Previous Comments: ------------------------------------------------------------------------ [2009-01-15 10:12:24] kobieta dot ryba at gmail dot com Is there anybody reading this? ------------------------------------------------------------------------ [2009-01-07 14:33:21] kobieta dot ryba at gmail dot com Description: ------------ I've noticed strange behavior when using references and foreach loop. It throws an error "Invalid argument supplied for foreach" but if the code // $ass = &$array; is commented out, the result is as expected: Output: in in in Reproduce code: --------------- <? $array = array("1", "2", "3"); $ass = &$array; foreach($array as $k => &$v) { $array = false; $v = "Test"; echo "in\n"; } ?> Expected result: ---------------- in in in Actual result: -------------- in Warning: Invalid argument supplied for foreach() in test.php on line 5 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=47028&edit=1
