Re: how many files are in a directory
| From: | Bas Jobsen | Date: | Wed, 14 Aug 2002 17:46:01 +0000 |
| Subject: | Re: how many files are in a directory | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-112572@lists.php.net to get a copy of this message | ||
Op woensdag 14 augustus 2002 20:00, schreef Harry.de:
> does anybody now a way in php to read out,
> how many files are in a directory
<?php
// Note that !== did not exist until 4.0.0-RC2
clearstatcache();
$dir='/home/';
if ($handle = opendir($dir))
{
echo "Directory handle: $handle\n";
$counter=0;
while (false !== ($file = readdir($handle)))
{
if(is_file($dir.'/'.$file))$counter++;
}
}
echo $counter."\n";
?>