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();
}
精彩评论