我正在寻找一种方法来测试 RecursiveDirectoryIterator 的对象输出的一部分。我知道如何识别文件夹,但我是 php 新手,不熟悉如何查看文件夹对象路径的内容......这可能吗?
我有以下内容:
foreach($files as $object){
$indent = str_repeat(' ', $files->getDepth());
if($object->isDir()){
//I know this is wrong... here is where I would want to find the string:
if($object contains 'mystring')){
echo "%%%-------found the string!\n";
}else{
echo $indent, "|| dir: $object\n";
}
}else{
echo $indent, "-- $object\n";
}
}