RegexIterator::accept

(PHP 5 >= 5.2.0, PHP 7)

RegexIterator::acceptGet accept status

Descrierea

public RegexIterator::accept ( ) : bool

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

Parametri

Această funcție nu are parametri.

Valorile întoarse

true if a match, false otherwise.

Exemple

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;
}
?>

Exemplul de mai sus va afișa:

Bob
Charlie
David

A se vedea și

add a note add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top