Edit report at https://bugs.php.net/bug.php?id=64403&edit=1
ID: 64403 Updated by: sala...@php.net Reported by: namarpi at yahoo dot com Summary: missing iterator object with RecursiveIteratorIterator::getInnerIterator -Status: Open +Status: Not a bug Type: Bug Package: SPL related Operating System: Windows XP PHP Version: 5.4.12 Block user comment: N Private report: N New Comment: The RecursiveIteratorIterator is only iterating over the "leaf nodes". It looks like you want to use the RecursiveIteratorIterator::SELF_FIRST or RecursiveIteratorIterator::CHILD_FIRST iteration mode (default is RecursiveIteratorIterator::LEAVES_ONLY). Previous Comments: ------------------------------------------------------------------------ [2013-03-11 11:05:49] namarpi at yahoo dot com Description: ------------ After using RecursiveIteratorIterator::getInnerIterator method in a loop, there is a missing RecursiveArrayIterator object in the result. For comparison, RecursiveIteratorIterator::getSubIterator method returns the expected result also. Test script: --------------- $array = array ( 'question' => 'text', 'items' => array ( '0' => array ( 'phrase' => 'text text', ), '1' => array ( 'phrase' => 'text text text', ), ), ); $array_object = new ArrayObject( $array, 0, "RecursiveArrayIterator" ); $iterator = new RecursiveIteratorIterator( $array_object->getIterator() ); foreach( $iterator as $key => $value ) { print_r( $iterator->getInnerIterator() ); // missing RecursiveArrayIterator Object of "items" } while( $iterator->valid() ) { print_r( $iterator->getInnerIterator() ); // missing RecursiveArrayIterator Object of "items" $iterator->next(); } foreach( $iterator as $key => $value ) { for( $i = 0; $i <= $iterator->getDepth(); $i++ ) { print_r( $iterator->getSubIterator($i) ); // correct } } Expected result: ---------------- The getInnerIterator method should return this object too: [11-Mar-2013 10:37:04 UTC] RecursiveArrayIterator Object ( [storage:ArrayIterator:private] => Array ( [0] => Array ( [phrase] => text text ) [1] => Array ( [phrase] => text text text ) ) ) Actual result: -------------- Missing the Expected result. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=64403&edit=1