<?php

$array = new ArrayIterator(array('a', array('b', 'c')));
$regex = new RegexIterator($array, '/Array/');
foreach ($regex as $match) {
    var_dump($match);
}
$rArrayIterator = new RecursiveArrayIterator(array('test1', array('tet3', 'test4', 'test5')));
$rRegexIterator = new RecursiveRegexIterator($rArrayIterator, '/^(t)est(\\d*)/', RecursiveRegexIterator::ALL_MATCHES, 0, PREG_PATTERN_ORDER);
foreach ($rRegexIterator as $key1 => $value1) {
    if ($rRegexIterator->hasChildren()) {
        // print all children
        echo "Children: ";
        foreach ($rRegexIterator->getChildren() as $key => $value) {
            print_r($value);
        }
        echo "\n";
    } else {
        echo "No children ";
        print_r($value1);
        echo "\n";
    }
}
<?php

$data = array(array('tet3', 'test4', 'test5'), array('tet2', 'test1'));
$iterator = new RecursiveRegexIterator(new RecursiveArrayIterator($data), '/^test/', RecursiveRegexIterator::ALL_MATCHES);
foreach ($iterator as $value) {
    foreach ($iterator->getChildren() as $value) {
        echo $value, PHP_EOL;
    }
}
<?php

// https://github.com/php/php-src/pull/865
$arr = new RecursiveArrayIterator([['test2', 'test3']]);
$regex = new RecursiveRegexIterator($arr, '/^test/', RecursiveRegexIterator::ALL_MATCHES, 1, 2);
$child = $regex->getChildren();
var_dump(get_class($child), $child->getMode(), $child->getFlags(), $child->getPregFlags());