note 48237 deleted from function.readdir by tularis
| From: | tularis@php.net | Date: | Sun, 13 May 2007 19:03:59 +0000 |
| Subject: | note 48237 deleted from function.readdir by tularis | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-126533@lists.php.net to get a copy of this message | ||
Note Submitter: boorick[at]utl[dot]ru
----
Simple script which counts directories and files in the set directory.
$path = '/path/to/dir'
if ($handle = opendir($path)) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
$fName = $file;
$file = $path.'/'.$file;
if(is_file($file)) $numfile++;
if(is_dir($file)) $numdir++;
};
};
closedir($handle);
};
echo $numfiles.' files in a directory';
echo $numdir.' subdirectory in directory';