xref: /PHP-5.5/ext/spl/tests/bug68128.phpt (revision 71ba5336)
1--TEST--
2Bug #68128 - RecursiveRegexIterator raises "Array to string conversion" notice
3--FILE--
4<?php
5
6$array = new ArrayIterator(array('a', array('b', 'c')));
7$regex = new RegexIterator($array, '/Array/');
8
9foreach ($regex as $match) {
10    var_dump($match);
11}
12
13$rArrayIterator = new RecursiveArrayIterator(array('test1', array('tet3', 'test4', 'test5')));
14$rRegexIterator = new RecursiveRegexIterator($rArrayIterator, '/^(t)est(\d*)/',
15    RecursiveRegexIterator::ALL_MATCHES, 0, PREG_PATTERN_ORDER);
16
17foreach ($rRegexIterator as $key1 => $value1) {
18
19    if ($rRegexIterator->hasChildren()) {
20
21        // print all children
22        echo "Children: ";
23        foreach ($rRegexIterator->getChildren() as $key => $value) {
24			print_r($value);
25        }
26        echo "\n";
27    } else {
28        echo "No children ";
29		print_r($value1);
30		echo "\n";
31    }
32}
33
34?>
35--EXPECT--
36No children Array
37(
38    [0] => Array
39        (
40            [0] => test1
41        )
42
43    [1] => Array
44        (
45            [0] => t
46        )
47
48    [2] => Array
49        (
50            [0] => 1
51        )
52
53)
54
55Children: Array
56(
57    [0] => Array
58        (
59            [0] => test4
60        )
61
62    [1] => Array
63        (
64            [0] => t
65        )
66
67    [2] => Array
68        (
69            [0] => 4
70        )
71
72)
73Array
74(
75    [0] => Array
76        (
77            [0] => test5
78        )
79
80    [1] => Array
81        (
82            [0] => t
83        )
84
85    [2] => Array
86        (
87            [0] => 5
88        )
89
90)
91
92