I have array like this:
array(
array(
'id' => 1,
'children' => array(
array(
'id' => 2,
'parent_id' => 1
),
array(
'id' => 3,
'parent_id' => 1,
'children' => array(
array(
'id' => 4,
'parent_id' => 3
)
)
)
)
)
);
The array goes deeper if it’s necessary. I need to get the children for any given id.
Thanks.
Unless I’m missing something, iterate over the array looking for something that matches the
idkey and the id you’re looking for (then return it as a result). You can also iteratively search (and give me a second to post code for that, which would examine theparentIdkey instead)…—
Recursive Version, Includes Children Elements:
Recursive Version, Excluding Children Elements