//$dir 目录名称
//$recursive 是否递归遍历
//reutrn 返回的全是文件绝对路径
public static function scanFile($dir,$recursive=false){
$dir = rtrim($dir,'/');
$pathList= scandir($dir);
$fileArr=[];
foreach($pathList as $path){
if(in_array($path,['.','..'])) continue;
$path = $dir.'/'.$path;
if(is_dir($path)){
if($recursive){
$fileArrIn = self::scanFile($path,true);
$fileArr = array_merge($fileArr,$fileArrIn);
}
}else{
$fileArr[] = $path;
}
}
return $fileArr;
}
posted on 2020-04-20 17:34  cyqAkin  阅读(184)  评论(0编辑  收藏  举报