xref: /PHP-7.2/ext/spl/tests/array_009a.phpt (revision 17ccbeec)
1--TEST--
2SPL: ArrayIterator implementing RecursiveIterator
3--FILE--
4<?php
5
6class MyRecursiveArrayIterator extends ArrayIterator implements RecursiveIterator
7{
8	function hasChildren()
9	{
10		return is_array($this->current());
11	}
12
13	function getChildren()
14	{
15		return new MyRecursiveArrayIterator($this->current());
16	}
17}
18
19$array = array(1, 2 => array(21, 22 => array(221, 222), 23 => array(231)), 3);
20
21$dir = new RecursiveIteratorIterator(new MyRecursiveArrayIterator($array), RecursiveIteratorIterator::LEAVES_ONLY);
22
23foreach ($dir as $file) {
24	print "$file\n";
25}
26
27?>
28===DONE===
29<?php exit(0); ?>
30--EXPECT--
311
3221
33221
34222
35231
363
37===DONE===
38