note 11695 deleted from function.next by jimw

From: Date: Thu, 20 Dec 2001 22:07:57 +0000
Subject: note 11695 deleted from function.next by jimw
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-23469@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.

« previous php.notes (#23469) next »