1--TEST-- 2SPL: Iterator using getInnerIterator 3--FILE-- 4<?php 5 6class RecursiceArrayIterator extends ArrayIterator implements RecursiveIterator 7{ 8 function hasChildren() 9 { 10 return is_array($this->current()); 11 } 12 13 function getChildren() 14 { 15 return new RecursiceArrayIterator($this->current()); 16 } 17} 18 19class CrashIterator extends FilterIterator implements RecursiveIterator 20{ 21 function accept() 22 { 23 return true; 24 } 25 26 function hasChildren() 27 { 28 return $this->getInnerIterator()->hasChildren(); 29 } 30 31 function getChildren() 32 { 33 return new RecursiceArrayIterator($this->getInnerIterator()->current()); 34 } 35} 36 37$array = array(1, 2 => array(21, 22 => array(221, 222), 23 => array(231)), 3); 38 39$dir = new RecursiveIteratorIterator(new CrashIterator(new RecursiceArrayIterator($array)), RecursiveIteratorIterator::LEAVES_ONLY); 40 41foreach ($dir as $file) { 42 print "$file\n"; 43} 44 45?> 46===DONE=== 47<?php exit(0); ?> 48--EXPECT-- 491 5021 51221 52222 53231 543 55===DONE=== 56