RegexIterator::accept

(PHP 5 >= 5.2.0, PHP 7)

RegexIterator::acceptGet accept status

说锟斤拷

public RegexIterator::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.

锟斤拷锟斤拷

Example #1 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

锟轿硷拷