xref: /PHP-8.0/ext/spl/tests/iterator_054.phpt (revision f8d79582)
1--TEST--
2SPL: RegexIterator::SPLIT
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, '/,/', RegexIterator::SPLIT);
20
21$it->show();
22
23var_dump($ar);
24
25?>
26--EXPECTF--
27int(1)
28array(2) {
29  [0]=>
30  string(1) "1"
31  [1]=>
32  string(1) "2"
33}
34int(2)
35array(3) {
36  [0]=>
37  string(1) "1"
38  [1]=>
39  string(1) "2"
40  [2]=>
41  string(1) "3"
42}
43int(7)
44array(2) {
45  [0]=>
46  string(0) ""
47  [1]=>
48  string(0) ""
49}
50int(8)
51array(3) {
52  [0]=>
53  string(0) ""
54  [1]=>
55  string(0) ""
56  [2]=>
57  string(0) ""
58}
59object(ArrayIterator)#%d (1) {
60  ["storage":"ArrayIterator":private]=>
61  array(9) {
62    [0]=>
63    %s(1) "1"
64    [1]=>
65    %s(3) "1,2"
66    [2]=>
67    %s(5) "1,2,3"
68    [3]=>
69    %s(0) ""
70    [4]=>
71    NULL
72    [5]=>
73    array(0) {
74    }
75    [6]=>
76    %s(6) "FooBar"
77    [7]=>
78    %s(1) ","
79    [8]=>
80    %s(2) ",,"
81  }
82}
83