RecursiveArrayIterator

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



When I run the code below, I get an output of the array which is good.
But the first member of the array output is 0=>Array. Is there a way to
prevent this? eg:

0 -- Array
name -- butch
sex -- m
breed -- boxer
name -- fido
sex -- m
breed -- doberman
name -- girly
sex -- f
breed -- poodle


<?php
$array = array(
    array('name'=>'butch', 'sex'=>'m', 'breed'=>'boxer'),
    array('name'=>'fido', 'sex'=>'m', 'breed'=>'doberman'),
    array('name'=>'girly','sex'=>'f', 'breed'=>'poodle')
);

$iterator =  new RecursiveIteratorIterator(new RecursiveArrayIterator($array));
while($iterator->valid())
    {
    echo $iterator->key().' -- '.$iterator->current().'<br/>';
    $iterator->next();
    }
?>

Kind regards
Kevin

-- 
"Democracy is two wolves and a lamb voting on what to have for lunch. 
Liberty is a well-armed lamb contesting the vote."

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux