(PHP 5 >= 5.2.0, PHP 7, PHP 8)
RegexIterator::getFlags — 取得旗標
此函式沒有參數。
返回設定的旗標。
範例 #1 RegexIterator::getFlags() 範例
<?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);
if ($regexIterator->getFlags() & RegexIterator::USE_KEY) {
echo '根據陣列鍵值進行篩選。';
} else {
echo '根據陣列值進行篩選。';
}
?>
上述範例將輸出:
Filtering based on the array keys.