我們用到了遞歸操作,不懂遞歸的小伙伴趕緊去google一下。
<?php
function getAllFiles($path){
foreach(scandir($path) as $file){
if($file === '.'|| $file === '..') continue;
if(is_dir($path.'/'.$file)) getAllFiles($path.'/'.$file);
else echo $path.'/'.$file."\n";
}
}
getAllFiles('/Usersm/test');
?>