|   | php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
| 
  [2002-02-09 07:58 UTC] laurent dot colson at freesbee dot fr
 Their is a bug when using readdir function with a directory 
named 0 is in the list.
Exemple :
Directory /home/www/perso
/home/www/perso/0 * 0 is a directory
/home/www/perso/1 * 1 is a directory
/home/www/perso/2 * 2 is a directory
The code :
	$ptr=opendir("/home/www/perso");
	while($fichier=readdir($ptr))
		echo "$fichier\n";
	closedir($ptr);
should be return :
.
..
0
1
2
however, it return only :
.
..
Cause of there is a directory named 0 in the structure.
Friendly,
Laurent
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits             | |||||||||||||||||||||||||||
|  Copyright © 2001-2025 The PHP Group All rights reserved. | Last updated: Thu Oct 30 20:00:01 2025 UTC | 
Yes, it works with : while(($fichier=readdir($ptr)) !== false) In fact, sorry, it's not really a bug, another thing which works than I tryed : do { $fichier=readdir($ptr); ... }while($fichier<>""); closedir($ptr); This works with the do structure because there is always 2 minimum derectories which are . and .. But your solution is better, thank you very much Friendly, Laurent