function read_all ($dir){ $str = explode('/',$dir); unset($str[0]); unset($str[1]); $string = implode('/', $str); if(!is_dir($dir)) { echo "文件读取失败!";die; } $handle = opendir($dir); if($handle){ $files = []; while(($file = readdir($handle)) !== false) { if ($file != ".." && $file != ".") { $path = $string.'/'.$file; if (is_dir($dir . "/" . $file)) { $files = array_merge($files,read_all($dir . "/" . $file)); } else { $files[] = $path; } } } closedir($handle); return $files; }else{ return false; } }
转载于:https://www.cnblogs.com/jingxiaoniu/p/9542141.html