/hphp/test/slow/ext_spl_iterators/bug68128.php
PHP | 39 lines | 32 code | 5 blank | 2 comment | 2 complexity | 0dd1aa3e1f0f9249605da922fbbb83e7 MD5 | raw file
Possible License(s): LGPL-2.1, BSD-2-Clause, BSD-3-Clause, MPL-2.0-no-copyleft-exception, MIT, LGPL-2.0, Apache-2.0
- <?hh
- // https://github.com/php/php-src/pull/865
- <<__EntryPoint>>
- function main_bug68128() {
- $array = new ArrayIterator(varray['a', varray['b', 'c']]);
- $regex = new RegexIterator($array, '/Array/');
- foreach ($regex as $match) {
- var_dump($match); // We should never get here
- }
- $rArrayIterator = new RecursiveArrayIterator(
- varray['test1', varray['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";
- }
- }
- }