RegexIterator::setPregFlags

(PHP 5 >= 5.2.0, PHP 7)

RegexIterator::setPregFlagsSets the regular expression flags

说明

public RegexIterator::setPregFlags ( int $preg_flags ) : void

Sets the regular expression flags.

参数

preg_flags

The regular expression flags. See RegexIterator::__construct() for an overview of available flags.

返回值

没有返回值。

范例

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

以上例程的输出类似于:

array(1) {
  [0]=>
  array(2) {
    [0]=>
    string(4) "test"
    [1]=>
    int(0)
  }
}
array(1) {
  [0]=>
  array(2) {
    [0]=>
    string(4) "test"
    [1]=>
    int(0)
  }
}

参见

相关文章
php arrayobject sets the behavior flagsphp gupnp 函数 sets a function to be called at regular intervalsphp imap 函数 sets flags on messagesphp 多字节字符串 函数 perform a regular expression search and replace with multibyte support using a callbackphp 多字节字符串 函数 replace regular expression with multibyte supportphp 多字节字符串 函数 returns start point for next regular expression matchphp 多字节字符串 函数 retrieve the result from the last multibyte regular expression matchphp 多字节字符串 函数 setup string and regular expression for a multibyte regular expression matchphp 多字节字符串 函数 returns position and length of a matched part of the multibyte regular expression for a predefined multibyte stringphp 多字节字符串 函数 returns the matched part of a multibyte regular expressionphp 多字节字符串 函数 set start point of next regular expression matchphp 多字节字符串 函数 multibyte regular expression match for predefined multibyte stringphp 多字节字符串 函数 regular expression match with multibyte supportphp pcre 函数 perform a regular expression search and replace using callbacksphp mongocursor sets arbitrary flags in case there is no method available the specific flagphp regexiterator returns the regular expression flagsphp regexiterator returns current regular expressionphp regexiterator sets the flagsphp regexiterator sets the regular expression flagsphp solrquery specify the regular expression for fragmenting
关注编程学问公众号