note 82787 deleted from function.opendir by felipe

From: Date: Sat, 26 Apr 2008 02:39:05 +0000
Subject: note 82787 deleted from function.opendir by felipe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-138790@lists.php.net to get a copy of this message
Note Submitter: Andy Watkins at php at wis dot co dot uk Reason: 5 ---- here's a gotcha! If you are using while ($file = readdir($dh)) { echo "$file\n"; } and your script comes across a directory called ./0 (i.e. zero), the expression will evaluate to false, and the loop will end unexpectedly. What you need to do is the following: while (($file = readdir($dh)) !== false) { echo "$file\n"; } closedir($dh);

« previous php.notes (#138790) next »