note 11695 added to next
| From: | mkknapp at quadrapod dot com | Date: | Fri, 02 Mar 2001 19:30:23 +0000 |
| Subject: | note 11695 added to next | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-11783@lists.php.net to get a copy of this message | ||
The problem with the do-while is that it runs once without checking if there is at least one element
in the array.
To traverse from the first element, AND protect against a possible empty array, try this:
if (count($array)) {
reset($array);
do{
//DO STUFF
} while (next ($array));
}
You could also use array_walk if you want to make a function out of the DO STUFF.
http://www.php.net/manual/en/function.next.php