Tuesday, June 7, 2011

PHP, count the total number of files in all directories



<?php

function s_glob($dir){
$files = array();
if(is_dir($dir)){
    if($dh=opendir($dir)){
    while((($file = readdir($dh)) !== false)){
    if ($file == '.' || $file == '..') {
          continue; }
        $files[]=$dir.$file;
    }}
}
return $files;
}
?>



<?php
$my_dir='/LMS/file_repository/proposals/committee/';
  echo  count(s_glob($my_dir));
?>

No comments:

Post a Comment