RegexIterator::setMode
SimpleXMLIterator
RegexIterator
PHP Manual

# RegexIterator::setPregFlags

(PHP 5 >= 5.2.0)

RegexIterator::setPregFlags — Sets the regular expression flags.

### 説明

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

Sets the regular expression flags.

### パラメータ

`preg_flags`

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

### 返り値

値を返しません。

### 例

例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)
      }
    }

### 参考

- RegexIterator::getPregFlags - Returns the regular expression flags.

RegexIterator::setMode
SimpleXMLIterator
RegexIterator
PHP Manual