有谁知道如何在 php 中递归地扫描目录?
$fileslist = array();
function readRecursive($dirname) {
global $fileslist;
$dir = scandir($dirname);
foreach ($dir as $f) {
if($f != "." && $f != ".." && $f != ".DS_Store") {
if(is_dir($dirname.DIRECTORY_SEPARATOR.$f)) {
$dname = $dirname.DIRECTORY_SEPARATOR.$f;
readRecursive($dname);
} else {
$fileslist[] = $dirname.DIRECTORY_SEPARATOR.$f;
}
}
}
}
以下代码不起作用提前谢谢