Help with is_file and is_dir
| From: | Lysa D. Milch | Date: | Thu, 03 Aug 2000 19:19:56 +0000 |
| Subject: | Help with is_file and is_dir | ||
| Groups: | php.windows | ||
| Request: | Send a blank email to php-windows+get-1534@lists.php.net to get a copy of this message | ||
I've got a script that's just confusing me.
It takes user input and displays the directories and files in that drive.
It'll open the directory (c:\ or d:\ or ANY mapped drive) and print out the
contents... but when i put a is_file() or is_dir conditional, it doesn't
even enter the loop. I wants to put the files into one array and the dirs
in another to sort later on...
Here's a snippet of code if anyone wants to help....
$handle = opendir($drive) ;
$fileCounter = 0 ;
$dirCounter = 0 ;
while ($file = readdir($handle))
{
if ($file != "." && $file != "..")
{
if (is_file($file) )
{
echo "in is_file loop" ;
$allFiles[$fileCounter] =
$file ;
$numFiles =
sizeof($allFiles);
$fileCounter++ ;
}
if (is_dir($file) )
{
echo "in is_dir loop" ;
$allDirs[$dirCounter] =
$file ;
$numDirs= sizeof($allDirs);
$dirCounter++ ;
}
}
}
closedir($handle);