Answers for "get file count in directory php"

PHP
5

php count number of files in directory

$fi = new FilesystemIterator(__DIR__, FilesystemIterator::SKIP_DOTS);
printf("There were %d Files", iterator_count($fi));
Posted by: Guest on May-07-2020
2

count files in folder php

// You can get the filecount like so:
$directory = "/path/to/dir/";
$filecount = 0;
$files = glob($directory . "*");
if ($files){
 $filecount = count($files);
}
echo "There were $filecount files";
// where the "*" is you can change that to a specific filetype if you want like "*.jpg" or you could do multiple filetypes like this:
// the GLOB_BRACE flag expands {a,b,c} to match 'a', 'b', or 'c'
// glob($directory . "*.{jpg,png,gif}",GLOB_BRACE);
Posted by: Guest on January-13-2022

Code answers related to "get file count in directory php"

Browse Popular Code Answers by Language