php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #2125 function dir, readdir does not list files/dirs named "0" (zero))
Submitted: 1999-08-22 19:00 UTC Modified: 1999-08-22 19:40 UTC
From: ivelin at iname dot com Assigned:
Status: Closed Package: Other
PHP Version: 3.0.12 OS: Linux 2.2.5
Private report: No CVE-ID: None
 [1999-08-22 19:00 UTC] ivelin at iname dot com
if you have 3 subdirs in the current dir, named 0, 1 and 2, only 1 and 2 would appear, but not 0

$dh = dir("./");
$i=0;
while($fname=readdir($dh)) {
	if ($fname != "." & $fname != "..") {
	    $dirs[$i++] = $fname;
	};
}
$dh->close();


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [1999-08-22 19:40 UTC] rasmus at cvs dot php dot net
Not really a bug.  Your while loop evaluates to while(0).  If you change it
to this:

  while(strlen(readdir($dh)) 

it should work fine.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue May 07 09:01:31 2024 UTC