Bug #1115: each() should reset array pointers by default?

From: Date: Tue, 02 Feb 1999 22:57:27 +0000
Subject: Bug #1115: each() should reset array pointers by default?
Groups: php.dev 
Request: Send a blank email to php-dev+get-3852@lists.php.net to get a copy of this message
From: charlie@k4azl.net Operating system: Linux 2.0.35 PHP version: 3.0.6 PHP Bug Type: Feature/Change Request Bug description: each() should reset array pointers by default? 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. -- PHP Development Mailing List http://www.php.net/ To unsubscribe send an empty message to php-dev-unsubscribe@lists.php.net For help: php-dev-help@lists.php.net

« previous php.dev (#3852) next »