xref: /PHP-8.4/ext/spl/tests/iterator_029.phpt (revision f8d79582)
1--TEST--
2SPL: RegexIterator
3--FILE--
4<?php
5
6$ar = array(0, "123", 123, 22 => "abc", "a2b", 22, "a2d" => 7, 42);
7
8foreach(new RegexIterator(new ArrayIterator($ar), "/2/") as $k => $v)
9{
10    echo "$k=>$v\n";
11}
12
13?>
14===KEY===
15<?php
16
17foreach(new RegexIterator(new ArrayIterator($ar), "/2/", 0, RegexIterator::USE_KEY) as $k => $v)
18{
19    echo "$k=>$v\n";
20}
21
22?>
23--EXPECT--
241=>123
252=>123
2623=>a2b
2724=>22
2825=>42
29===KEY===
302=>123
3122=>abc
3223=>a2b
3324=>22
34a2d=>7
3525=>42
36