Return total number of files within a folder using PHP

前端 未结 10 941
花落未央
花落未央 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:05

    $nfiles = glob("/path/to/file/[!\\.]*");
    
    if ($nfiles !== FALSE){
    
        return count($nfiles);
    
    } else {
    
        return 0;
    
    }
    

提交回复
热议问题