|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2005-07-15 22:01 UTC] helly@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Thu Jan 01 21:00:01 2026 UTC |
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