ID:               44063
 Updated by:       [EMAIL PROTECTED]
 Reported By:      smirnov at h-type dot com
 Status:           Open
 Bug Type:         SPL related
 Operating System: Windows
 PHP Version:      5.2.5
 New Comment:

Marcus, is my impression or is missing a rewind in this constructor?

http://felipe.ath.cx/diff/bug44063.diff


Previous Comments:
------------------------------------------------------------------------

[2008-02-06 14:28:08] smirnov at h-type dot com

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


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=44063&edit=1

Reply via email to