I have an array like this:
$arr = array(
$foo = array(
\'donuts\' => array(
\'name\' => \'lionel ritchie\',
You can access the iterator via getSubIterator, and in your case you want the key:
<?php
$arr = array(
$foo = array(
'donuts' => array(
'name' => 'lionel ritchie',
'animal' => 'manatee',
)
)
);
$iterator = new RecursiveIteratorIterator(new RecursiveArrayIterator($arr));
foreach ($iterator as $key => $value) {
// loop through the subIterators...
$keys = array();
// in this case i skip the grand parent (numeric array)
for ($i = $iterator->getDepth()-1; $i>0; $i--) {
$keys[] = $iterator->getSubIterator($i)->key();
}
$keys[] = $key;
echo implode(' ',$keys).': '.$value.'<br>';
}
?>