note 106848 added to class.recursivecallbackfilteriterator
| From: | Anonymous at osu1 dot php dot net | Date: | Sun, 11 Dec 2011 21:31:54 +0000 |
| Subject: | note 106848 added to class.recursivecallbackfilteriterator | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-185056@lists.php.net to get a copy of this message | ||
Note that the following filters out both files and directories whos names start with the letter
"T". The important thing here is that since the function returns false for a directory
entry whos name starts with T, the directory is also not traversed recursively.
<?php
$doesntStartWithLetterT = function ($current) {
return $current->getFileName()[0] !== 'T';
};
$rdi = new RecursiveDirectoryIterator(__DIR__);
$files = new RecursiveCallbackFilterIterator($rdi, $doesntStartWithLetterT);
foreach (new RecursiveIteratorIterator($files) as $file) {
echo $file->getPathname() . PHP_EOL;
}
?>
----
Server IP: 69.147.83.197
Probable Submitter: 76.14.54.90
----
Manual Page -- http://www.php.net/manual/en/class.recursivecallbackfilteriterator.php
Edit -- https://master.php.net/note/edit/106848
Del: integrated -- https://master.php.net/note/delete/106848/integrated
Del: useless -- https://master.php.net/note/delete/106848/useless
Del: bad code -- https://master.php.net/note/delete/106848/bad+code
Del: spam -- https://master.php.net/note/delete/106848/spam
Del: non-english -- https://master.php.net/note/delete/106848/non-english
Del: in docs -- https://master.php.net/note/delete/106848/in+docs
Del: other reasons-- https://master.php.net/note/delete/106848
Reject -- https://master.php.net/note/reject/106848
Search -- https://master.php.net/manage/user-notes.php