array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'de', ), 'this' => array ( 0 => 'regexiterator.setpregflags.php', 1 => 'RegexIterator::setPregFlags', 2 => 'Sets the regular expression flags', ), 'up' => array ( 0 => 'class.regexiterator.php', 1 => 'RegexIterator', ), 'prev' => array ( 0 => 'regexiterator.setmode.php', 1 => 'RegexIterator::setMode', ), 'next' => array ( 0 => 'spl.files.php', 1 => 'File Handling', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'en', 'path' => 'reference/spl/regexiterator/setpregflags.xml', ), 'history' => array ( ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); contributors($setup); ?>
(PHP 5 >= 5.2.0, PHP 7, PHP 8)
RegexIterator::setPregFlags — Sets the regular expression flags
Sets the regular expression flags.
pregFlags
The regular expression flags. See RegexIterator::__construct() for an overview of available flags.
Es wird kein Wert zurückgegeben.
Beispiel #1 RegexIterator::setPregFlags() example
Creates a new RegexIterator that filters all entries with where the array key starts with 'test'.
<?php
$test = array ('test 1', 'another test', 'test 123');
$arrayIterator = new ArrayIterator($test);
$regexIterator = new RegexIterator($arrayIterator, '/^test/', RegexIterator::GET_MATCH);
$regexIterator->setPregFlags(PREG_OFFSET_CAPTURE);
foreach ($regexIterator as $key => $value) {
var_dump($value);
}
?>
Das oben gezeigte Beispiel erzeugt eine ähnliche Ausgabe wie:
array(1) { [0]=> array(2) { [0]=> string(4) "test" [1]=> int(0) } } array(1) { [0]=> array(2) { [0]=> string(4) "test" [1]=> int(0) } }