• 首页
  • vue
  • TypeScript
  • JavaScript
  • scss
  • css3
  • html5
  • php
  • MySQL
  • redis
  • jQuery
  • RegexIterator::accept()

    (PHP 5 >= 5.2.0, PHP 7)

    Get accept status

    说明

    publicRegexIterator::accept(void): bool

    Matches (string)RegexIterator::current()(or RegexIterator::key() if the RegexIterator::USE_KEY flag is set)against the regular expression.

    参数

    此函数没有参数。

    返回值

    TRUE if a match,FALSE otherwise.

    范例

    RegexIterator::accept() example

    This example shows that only items matching the regular expression are accepted.

    <?php
    $names = new ArrayIterator(array('Ann', 'Bob', 'Charlie', 'David'));
    $filter = new RegexIterator($names, '/^[B-D]/');
    foreach ($filter as $name) {
        echo $name . PHP_EOL;
    }
    ?>
    

    以上例程会输出:

    Bob
    Charlie
    David
    

    参见

    • RegexIterator constants
    • RegexIterator::setFlags() Sets the flags