echo countFiles('/usr/local/'); // outputs 27 function countFiles($dir){
$files = array();
$directory = opendir($dir);
while($item = readdir($directory)){
// We filter the elements that we don't want to appear ".", ".." and ".svn"
if(($item != ".") && ($item != "..") && ($item != ".svn") ){
$files[] = $item;
}
}
$numFiles = count($files);
return $numFiles;
} ?>
No comments:
Post a Comment