开发者

is it possible to get files from a root directory and sub directories with glob?

开发者 https://www.devze.com 2023-02-09 18:45 出处:网络
I\'m working on a script that when ran uses glob() to get all the files from a directory that is passed through an arg, and then check their modification time. I开发者_如何学JAVAs it possible to have

I'm working on a script that when ran uses glob() to get all the files from a directory that is passed through an arg, and then check their modification time. I开发者_如何学JAVAs it possible to have glob() go through the files in the dir, and the files in the sub dirs?


Is glob() a requirement? For a recursive implementation I prefer using RecursiveDirectoryIterator(). This does the same job in a much more readable way.

$realpath = realpath('/path/to/file');


$fileObjects = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($realpath));

foreach($fileObjects as $key => $object){
    echo $object->getFilename();
} 
0

精彩评论

暂无评论...
验证码 换一张
取 消