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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
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

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: Wed May 08 02:01:32 2024 UTC