xref: /PHP-7.1/ext/spl/tests/iterator_050.phpt (revision 71ba5336)
1--TEST--
2SPL: RegexIterator::GET_MATCH
3--FILE--
4<?php
5
6class MyRegexIterator extends RegexIterator
7{
8	function show()
9	{
10		foreach($this as $k => $v)
11		{
12			var_dump($k);
13			var_dump($v);
14		}
15	}
16}
17
18$ar = new ArrayIterator(array('1','1,2','1,2,3','',NULL,array(),'FooBar',',',',,'));
19$it = new MyRegexIterator($ar, '/(\d),(\d)/', RegexIterator::GET_MATCH);
20$it->show();
21
22$it = new MyRegexIterator($ar, '/(\d)/', RegexIterator::GET_MATCH);
23$it->show();
24
25var_dump($ar);
26
27?>
28===DONE===
29<?php exit(0); ?>
30--EXPECTF--
31int(1)
32array(3) {
33  [0]=>
34  %s(3) "1,2"
35  [1]=>
36  %s(1) "1"
37  [2]=>
38  %s(1) "2"
39}
40int(2)
41array(3) {
42  [0]=>
43  %s(3) "1,2"
44  [1]=>
45  %s(1) "1"
46  [2]=>
47  %s(1) "2"
48}
49int(0)
50array(2) {
51  [0]=>
52  %s(1) "1"
53  [1]=>
54  %s(1) "1"
55}
56int(1)
57array(2) {
58  [0]=>
59  %s(1) "1"
60  [1]=>
61  %s(1) "1"
62}
63int(2)
64array(2) {
65  [0]=>
66  %s(1) "1"
67  [1]=>
68  %s(1) "1"
69}
70object(ArrayIterator)#%d (1) {
71  %s"storage"%s"ArrayIterator":private]=>
72  array(9) {
73    [0]=>
74    %s(1) "1"
75    [1]=>
76    %s(3) "1,2"
77    [2]=>
78    %s(5) "1,2,3"
79    [3]=>
80    %s(0) ""
81    [4]=>
82    NULL
83    [5]=>
84    array(0) {
85    }
86    [6]=>
87    %s(6) "FooBar"
88    [7]=>
89    %s(1) ","
90    [8]=>
91    %s(2) ",,"
92  }
93}
94===DONE===
95