我正在尝试显示目录中所有文件夹的列表。但我不希望列出任何包含“thumbs”一词的文件夹。有人可以告诉我该怎么做...这是我正在使用的代码,它似乎不起作用。它会显示所有文件夹,但不会阻止其中带有“thumbs”一词的文件夹。
<?php
$dir = new RecursiveDirectoryIterator('puzzle/images/puzzles/',
FilesystemIterator::SKIP_DOTS);
$it = new RecursiveIteratorIterator($dir,
RecursiveIteratorIterator::SELF_FIRST);
$it->setMaxDepth(1);
foreach ($it as $fileinfo) {
if ($fileinfo == '*thumbs') {
// PLACEHOLDER
} elseif ($fileinfo->isDir()) {
echo $fileinfo . "<br><br>";
}
}
?>
输出看起来像这样......
puzzle/images/puzzles/vehicles
puzzle/images/puzzles/vehicles/thumbs
puzzle/images/puzzles/scenery
puzzle/images/puzzles/scenery/thumbs
puzzle/images/puzzles/movies
puzzle/images/puzzles/movies/thumbs
puzzle/images/puzzles/thumbnails
puzzle/images/puzzles/holidays
puzzle/images/puzzles/holidays/thumbs
puzzle/images/puzzles/holidays/thanksgiving
这就是我希望输出的样子,除了没有以下文件夹......
puzzle/images/puzzles/vehicles/thumbs
puzzle/images/puzzles/scenery/thumbs
puzzle/images/puzzles/movies/thumbs
puzzle/images/puzzles/holidays/thumbs
或者我稍后放入的任何名为“thumbs”的未来文件夹。