|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2008-02-07 01:07 UTC] felipe@php.net
[2008-02-07 09:32 UTC] helly@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 16:00:01 2025 UTC |
Description: ------------ RecursiveIteratorIterator returns one extra result if we don't provide rewind() before while. Reproduce code: --------------- $array = array( array('name'=>'butch', 'sex'=>'male'), array('name'=>'fido', 'sex'=>'male'), array('name'=>'girly','sex'=>'female') ); $it=new RecursiveIteratorIterator(new RecursiveArrayIterator($array)); //$it->rewind(); //The result will be as expected if uncomment this while($it->valid()){ echo $it->key().' -- '.$it->current()."\n"; $it->next(); } Expected result: ---------------- name -- butch sex -- male name -- fido sex -- male name -- girly sex -- female Actual result: -------------- 0 -- Array name -- butch sex -- male name -- fido sex -- male name -- girly sex -- female