PHP Doku:: Get accept status - regexiterator.accept.html

Verlauf / Chronik / History: (4) anzeigen

Sie sind hier:
Doku-StartseitePHP-HandbuchFunktionsreferenzSonstige GrunderweiterungenStandard PHP Library (SPL)IteratorenThe RegexIterator classRegexIterator::accept

Ein Service von Reinhard Neidl - Webprogrammierung.

The RegexIterator class

<<The RegexIterator class

RegexIterator::__construct>>

RegexIterator::accept

(PHP 5 >= 5.2.0)

RegexIterator::acceptGet accept status

Beschreibung

public bool RegexIterator::accept ( void )

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

Parameter-Liste

Diese Funktion hat keine Parameter.

Rückgabewerte

TRUE if a match, FALSE otherwise.

Beispiele

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

Das oben gezeigte Beispiel erzeugt folgende Ausgabe:

Bob
Charlie
David

Siehe auch


Keine BenutzerBeiträge.
- Beiträge aktualisieren...



PHP Powered Diese Seite bei php.net
The PHP manual text and comments are covered by the Creative Commons Attribution 3.0 License © the PHP Documentation Group - Impressum - mail("TO:Reinhard Neidl",...)