[英]Is it possible to put my connection file in the Root Directory and fetch data from sub directories?
[英]is it possible to get files from a root directory and sub directories with glob?
我正在处理一个脚本,该脚本在运行时使用glob()从通过arg传递的目录中获取所有文件,然后检查其修改时间。 是否可以让glob()浏览目录中的文件以及子目录中的文件?
是否需要glob()
? 对于递归实现,我更喜欢使用RecursiveDirectoryIterator()
。 这以更易读的方式完成了相同的工作。
$realpath = realpath('/path/to/file');
$fileObjects = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($realpath));
foreach($fileObjects as $key => $object){
echo $object->getFilename();
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.