コード例 #1
0
 public function __construct(RecursiveIterator $it, $regex)
 {
     $this->regex = $regex;
     parent::__construct($it, $this->regex);
 }
コード例 #2
0
 /**
  * RegexFilter constructor.
  * @param \RecursiveIterator $iterator
  * @param string $regex
  */
 public function __construct(RecursiveIterator $iterator, $regex)
 {
     $this->iterator = $iterator;
     $this->regex = $this->toRegex($regex);
     parent::__construct($iterator, $this->regex);
 }
コード例 #3
0
ファイル: iterator_048.php プロジェクト: badlamer/hhvm
 function accept()
 {
     return $this->hasChildren() || parent::accept();
 }
コード例 #4
0
<?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;
    }
}
コード例 #5
0
<?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";
    }
}
コード例 #6
0
<?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());
 /**
  * Simply invert the accept() function
  *
  */
 public function accept()
 {
     return !parent::accept();
 }