|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2000-05-19 09:52 UTC] hholzgra at cvs dot php dot net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Nov 06 08:00:01 2025 UTC |
each() doesn't reset an array's internal pointer to the first element after executing, which can cause a lot of headaches if you expect that to be the case... I don't know if this is intentional or an oversight, and I can imagine it being either one. For instance: <? echo "<pre>firstpass\n\n"; while ( list( $k, $v ) = each( $GLOBALS ) ) { echo "\n$k => $v"; } echo "\n\nsecondpass"; while ( list( $k, $v ) = each( $GLOBALS ) ) { echo "\n$k => $v"; } ?> Will output this to the browser: firstpass GLOBALS => HTTP_GET_VARS => Array HTTP_COOKIE_VARS => Array INIT_VERSION => sysvinit-2.69 TERM => linux etc.... secondpass <i>nothing at all...</i> Of course this can be fixed by adding a call to reset($somearray) after each call to each($somearray), but that doesn't seem very intuitive.