【发布时间】:2013-04-29 15:12:49
【问题描述】:
我发现我可以在php中使用以下代码获取文件夹的所有子目录
$address = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($root, RecursiveDirectoryIterator::SKIP_DOTS),
RecursiveIteratorIterator::SELF_FIRST,
RecursiveIteratorIterator::CATCH_GET_CHILD // Ignore "Permission denied"
);
并将其放入 $address 中。
如何再添加一个条件并说明子目录中是否包含“tmp”文件夹,然后将其放入 $address 中?
【问题讨论】:
-
澄清一下:你想要/path/to in address 还是/path/to/tmp. “put it in the $address”中的“it”有点模棱两可。
-
@wikinevis 的意思是
/path/to无效,因为它在路径中有tmp吗?因为path/to/tmp还显示path/to/中有文件夹.....可以用示例输出更新您的答案
标签: php directory subdirectory