|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2000-10-22 19:12 UTC] whit at transpect dot com
This snippet works:
$handle=opendir($homedir);
while ($file = readdir($handle)) {
$retval[count($retval)] = $file;
}
closedir($handle);
sort($retval);
$cnt=count($retval);
echo "CNT: $cnt";
$int=0;
while($int<$cnt) {
if(!is_dir($retval[$int])) {
echo "File: $retval[$int]<br>";
} else {
echo "Dir: $retval[$int]<br>";
}
$int++;
}
But if I change "if(!is_dir($retval[$int])) {" to "if(is_file($retval[$int])) {" it fails.
The way it fails is that all of the files fail to match as files, and are shown prefixed by "Dir:".
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 02 05:00:01 2025 UTC |
I could not reproduce the bug with a modified code, main difference is that I am using the full path in the is_file() function, as it should be. Code below works on PHP 4.0.3pl1 (RedHat 6.1 and Solaris 2.6): $dir ="/path/to/phpdoc/en"; $handle=opendir($dir); while ($file = readdir($handle)) { $retval[count($retval)] = $dir."/".$file; } closedir($handle); sort($retval); $cnt=count($retval); echo "CNT: $cnt\n"; $int=0; while($int<$cnt) { if(is_file($retval[$int])) { echo "File: ".$retval[$int]."\n"; } else { echo "Dir: ".$retval[$int]."\n"; } $int++; }