Recursive function for multidimensional array
- by moja
This is my code,
and I need your help to understand it.
<?php $tree = array(
array(
'name' => 'Item-1',
'children' => array()),
array('name' => 'Item-2',
'children' => array(
array('name' => 'Item-2-1',
'children' => array()),
)),
array('name' => 'Item-3',
'children' => array(
array('name' => 'Item-3-1',
'children' => array()),
array('name' => 'Item-3-2',
'children' => array(
array('name' => 'Item-3-2-1',
'children' => array()),
array('name' => 'Item-3-2-2',
'children' => array()),
array('name' => 'Item-3-2-3',
'children' => array(
array('name' => 'Item-3-2-3-1',
'children' => array()),
)),
)),
)),
);
What i need is one recursive function, which will return all names (name).
For example:
Item-1
Item-2
Item-2-1
Item-3
Item-3-1
Item-3-2
........
Thanks for your help.