/**
* 使用scandir 遍历目录并返回所有文件绝对路径
*
* @param $path
* @return array
*/
function getFile($path)
{
//判断目录是否为空
if(!file_exists($path)) {
return array();
}
$files = scandir($path);
$fileItem = array();
foreach($files as $v) {
$newPath = $path .DIRECTORY_SEPARATOR . $v;
if(is_dir($newPath) && $v != '.' && $v != '..') {
$fileItem = array_merge($fileItem, getFile($newPath));
}else if(is_file($newPath)){
$fileItem[] = $newPath;
}
}
return $fileItem;
}
遍历文件夹下的所有文件
最新推荐文章于 2024-03-05 12:21:13 发布