Return total number of files within a folder using PHP

前端 未结 10 959
花落未央
花落未央 2020-12-28 20:31

Is there a better/simpler way to find the number of images in a directory and output them to a variable?

function dirCount($dir) {
  $x = 0;
  while (($file          


        
10条回答
  •  太阳男子
    2020-12-28 21:03

    I use this to return a count of ALL files in a directory except . and ..

    return count(glob("/path/to/file/[!\.]*"));
    

    Here is a good list of glob filters for file matching purposes.

提交回复
热议问题