표준 PHP 라이브러리(SPL) RegexIterator::setFlags
(PHP 5 >= 5.2.0, PHP 7, PHP 8)
RegexIterator::setFlags — Sets the flags
설명
public RegexIterator::setFlags(int $flags
): void
플래그를 설정합니다.
매개변수
flags
- 설정할 플래그, 클래스 상수의 비트 마스크.
사용 가능한 플래그는 다음과 같습니다. 이러한 플래그의 실제 의미는 미리 정의된 상수에 설명되어 있습니다.
RegexIterator flags
value constant 1 RegexIterator::USE_KEY
반환 값
값이 반환되지 않습니다.
Examples
예제 #1 RegexIterator::setFlags() 예제
키가 'test'로 시작하는 모든 항목을 필터링하는 새 RegexIterator를 만듭니다.
<?php
$test = array ('str1' => 'test 1', 'teststr2' => 'another test', 'str3' => 'test 123');
$arrayIterator = new ArrayIterator($test);
$regexIterator = new RegexIterator($arrayIterator, '/^test/');
$regexIterator->setFlags(RegexIterator::USE_KEY);
foreach ($regexIterator as $key => $value) {
echo $key . ' => ' . $value . "\n";
}
?>
위의 예는 다음을 출력합니다.
teststr2 => another test
기타
- RegexIterator::getFlags() - Get flags