I have an array with a data structure like below
$array = array(
'someKey' => array(
'id' => 1,
'string' => 'some key',
'someKey2' => array(
'id' => 1,
'string' => 'some key two',
'someKeyThree' => array(
'id' => 1,
'string' => 'some key three',
,
),
),
'someOtherKey' => array(
),
);
What I would like to do is out every array as a nested div p structure,
<div>
<p>someKey</p> // key of first array value
<div>
<p>someKey2</p>
<div>
<p>SomeKeyThree</p>
</div>
</div>
</div>
I have tried using new RecursiveIteratorIterator(new RecursiveArrayIterator($this->getData(), RecursiveIteratorIterator::CHILD_FIRST));
and using that but I am having trouble as the end tag for div never ends up right. Also once the iterator reaches the bottom of an array with no array to go into I want it to stop iterating completely.
THanks
arrayIteratoris not the best I am having trouble with. I would also like the iteration to stop if no array is found within that iteration, thank you.