php算法-遍历文件夹
发布时间:2021-12-16 14:05:27编辑:admin
function
findDir(
$dir
){
$handel
= openDir(
$dir
);
$files
= [];
while
(false !== (
$file
= readdir(
$handel
))){
if
(
$file
==
'.'
||
$file
==
'..'
){
continue
;
}
$subDir
=
realpath
(
$dir
.
'/'
.
$file
);
if
(
is_dir
(
$subDir
)){
$files
[
$subDir
] = findDir(
$subDir
);
}
else
{
$files
[] =
$file
;
}
}
closedir
(
$handel
);
return
$files
;
}