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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: ivelin at iname dot com
New email:
PHP Version: OS:

 

 [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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Sun Jan 05 03:01:28 2025 UTC