2006-05-10 08:29:42 +08:00
|
|
|
--TEST--
|
2006-05-11 00:50:57 +08:00
|
|
|
SPL: RegexIterator
|
2006-05-10 08:29:42 +08:00
|
|
|
--FILE--
|
|
|
|
<?php
|
|
|
|
|
|
|
|
$ar = array(0, "123", 123, 22 => "abc", "a2b", 22, "a2d" => 7, 42);
|
|
|
|
|
2006-05-11 00:50:57 +08:00
|
|
|
foreach(new RegexIterator(new ArrayIterator($ar), "/2/") as $k => $v)
|
2006-05-10 08:29:42 +08:00
|
|
|
{
|
|
|
|
echo "$k=>$v\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|
|
|
|
===KEY===
|
|
|
|
<?php
|
|
|
|
|
2006-07-22 04:14:31 +08:00
|
|
|
foreach(new RegexIterator(new ArrayIterator($ar), "/2/", 0, RegexIterator::USE_KEY) as $k => $v)
|
2006-05-10 08:29:42 +08:00
|
|
|
{
|
|
|
|
echo "$k=>$v\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|
|
|
|
===DONE===
|
|
|
|
<?php exit(0); ?>
|
|
|
|
--EXPECT--
|
|
|
|
1=>123
|
|
|
|
2=>123
|
|
|
|
23=>a2b
|
|
|
|
24=>22
|
|
|
|
25=>42
|
|
|
|
===KEY===
|
|
|
|
2=>123
|
|
|
|
22=>abc
|
|
|
|
23=>a2b
|
|
|
|
24=>22
|
|
|
|
a2d=>7
|
|
|
|
25=>42
|
|
|
|
===DONE===
|