Jump to content

Number of files in directory and subdir


AndrewFerrara

Recommended Posts

 

Displaying the number of files in a directory and its subdirectorys

 

<?php

$path = './images_cache';
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';

?>

Link to comment
https://forums.phpfreaks.com/topic/225915-number-of-files-in-directory-and-subdir/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.