PHP遍历某一文件夹下所有文件

2016-05-20  本文已影响188人  Fa1se003

我们用到了递归操作,不懂递归的小伙伴赶紧去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');
?>

上一篇 下一篇

猜你喜欢

热点阅读