note 49677 added to control-structures.foreach

From: Date: Fri, 04 Feb 2005 14:07:48 +0000
Subject: note 49677 added to control-structures.foreach
Groups: php.notes 
Request: Send a blank email to php-notes+get-84524@lists.php.net to get a copy of this message
Interestingly enough to post it here, I guess. If you want to get only keys from an array, while...list...each approach is faster than foreach. <?php while(list($key) = each($array)) { echo "$key <br>\n"; } foreach($array as $key => $value) { echo "$key <br>\n"; } ?> It makes sense, since you cannot call only keys from an array with foreach(). ---- Manual Page -- http://www.php.net/manual/en/control-structures.foreach.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+49677 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+49677&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+49677&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+49677&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+49677&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+49677&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+49677&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#84524) next »