[php-src] Issue #7730: RecursiveRegexIterator
| From: | noreply@php.net | Date: | Tue, 07 Dec 2021 11:42:54 +0000 |
| Subject: | [php-src] Issue #7730: RecursiveRegexIterator | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-238246@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/7730
Comment Author: iluuu1994
@WinterSilence If you want recursion you also need
RecursiveIteratorIterator.
That's because the RecursiveDirectoryIterator actually yields other iterators, not
just a flat list of directories.
```php
$directory = new RecursiveDirectoryIterator(__DIR__);
$iterator = new RecursiveIteratorIterator($directory);
$regex = new RegexIterator(
$iterator,
'/((?:[A-Z][a-zA-Z\d]+\/)*[A-Z][a-zA-Z\d]+)\.php$/',
RegexIterator::GET_MATCH,
RegexIterator::USE_KEY
);
var_dump(iterator_to_array($regex));
```