hiphop-php /hphp/test/slow/ext_spl_iterators/bug68128.php

Language PHP Lines 36
MD5 Hash 4333b4d6c0ff38b661244ea5a76d5ae2 Estimated Cost $633 (why?)
Repository git://github.com/facebook/hiphop-php.git View Raw File View Project SPDX
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php
// https://github.com/php/php-src/pull/865

$array = new ArrayIterator(array('a', array('b', 'c')));
$regex = new RegexIterator($array, '/Array/');

foreach ($regex as $match) {
  var_dump($match); // We should never get here
}

$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";
  }
}
Back to Top