RegexIterator::accept

(PHP 5 >= 5.2.0, PHP 7, PHP 8)

RegexIterator::acceptGet accept status

Açıklama

publicRegexIterator::accept(): bool

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

Bağımsız Değişkenler

Bu işlevin bağımsız değişkeni yoktur.

Dönen Değerler

true if a match, false otherwise.

Örnekler

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

Yukarıdaki örneğin çıktısı:

Bob Charlie David

Ayrıca Bakınız

To Top