我需要创建一个遍历子目录中所有文件的循环。您能帮我构造我的代码吗?
$main = "MainDirectory"; loop through sub-directories { loop through filels in each sub-directory { do something with each file } };
将RecursiveDirectoryIterator与RecursiveIteratorIterator结合使用。
$di = new RecursiveDirectoryIterator('path/to/directory'); foreach (new RecursiveIteratorIterator($di) as $filename => $file) { echo $filename . ' - ' . $file->getSize() . ' bytes <br/>'; }