note 49677 deleted from control-structures.foreach by aidan
| From: | aidan@php.net | Date: | Sat, 12 Mar 2005 00:38:25 +0000 |
| Subject: | note 49677 deleted from control-structures.foreach by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-86314@lists.php.net to get a copy of this message | ||
Note Submitter: djelenc at gmail dot com
----
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().