php递归取目录下的所有文件(原创)

function get_dir_all_files($path)
{
    $result=array();
    $temp=array();
        
    if(filetype($path)=='dir')
    {
        $dir=scandir($path);
        foreach($dir as $value)
        {
            if($value!='.'&&$value!='..')
            {
                if(filetype("$path/$value")!='dir')
                {
                    $result[]="$path/$value";                    
                }else
                {
                    $temp=array_merge($temp,get_dir_all_files("$path/$value"));
                }        
            }
        }
    }
    return array_merge($result,$temp);;
}
 
原文地址:https://www.cnblogs.com/zhudongchang/p/3896664.html