ID: 33713 Updated by: [EMAIL PROTECTED] Reported By: bmorel at ssi dot fr -Status: Open +Status: Bogus Bug Type: Scripting Engine problem -Operating System: Fedora Core 4 +Operating System: * -PHP Version: 5.0.4 +PHP Version: 5.* 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 Use ArrayObject/ArrayIterator instead or as a wrapper around your arrays. Previous Comments: ------------------------------------------------------------------------ [2005-07-15 18:41:52] bmorel at ssi dot fr Description: ------------ Sorry if this is not a bug, but I think the behavior is not normal, even after searching the net and this bug database. It seems that, used inside a recursive function, foreach doesn't use different array pointers for each iteration of the function, but uses the same at each time. This common pointer is reseted at each foreach() call. Reproduce code: --------------- function recurse($doRecurse = true) { static $array = array(1,2); foreach ($array as $value) { echo $value . PHP_EOL; if ($doRecurse) recurse(false); } } recurse(); Expected result: ---------------- 1 1 2 2 1 2 Actual result: -------------- 1 1 2 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=33713&edit=1