I have an array looking like this:
$arr = array(
array(
'name' => 'n1',
'id' => 0,
'children' => array(
array(
'name' => 'n2',
'id' => 1,
'children' => array(
array(
'name' => 'n3',
'id' => 2,
'children' => array(),
),
array(
'name' => 'n4',
'id' => 3,
'children' => array(),
),
),
),
array(
'name' => 'n17',
'id' => 4,
'children' => array(),
),
),
),
);
but on a bigger scale.
I want to write a php recursive function which receives the id of the searched element as argument and returns the names it went through to get there, for example, for id==4, the result should be:
array('n1', 'n17');