时间:2021-07-01 10:21:17 帮助过:19人阅读
"; }?>]
减少遍历的范围是唯一优化的方法
使用 glob 不递归或目录迭代器可使速度提高,但也有限
$p = './';$res = glob("$p/*");for($i=0; $i $path = '.';$ite = new RecursiveIteratorIterator( new RecursiveDirectoryIterator($path) );$deep = 0;foreach ($ite as $cur) { $fn = $cur->getBasename(); if($fn == '.' || $fn == '..') continue; $res[] = $fn; if(($d=$ite->getDepth()) == $deep); echo "$d $fn
";}