Return to Snippet

Revision: 16402
at August 3, 2009 09:55 by fackz


Initial Code
<?php
function count_files($name) {
$dirname = "galleries/$name";
if(is_dir($dirname))
$dir_handle = opendir($dirname);
if(!$dir_handle)
return false;

$files = 0;

while($file = readdir($dir_handle)) {
if($file != "." and $file != "..") {
if(!is_dir($dirname . "/" . $file))
$files++;
else
$files += count_files($dirname . "/" . $file);
}
}

closedir($dir_handle);

return $files;
}
?>

Initial URL

                                

Initial Description
count files in a given dir

Initial Title
count files in a given dir

Initial Tags
files

Initial Language
PHP