Hai first take a look at this array,
Array
(
[0] => Array
(
[id] => 4
[parent_id] => 3
[children] => Array
(
[0] => Array
(
[id] => 7
[parent_id] => 4
[children] => Array
(
[0] => Array
(
[id] => 6
[parent_id] => 7
[children] => Array
(
[0] => Array
(
[id] => 2
[parent_id] => 6
)
)
)
)
)
)
)
[1] => Array
(
[id] => 5
[parent_id] => 3
)
)
i need a output of all id [IE: 4, 7, 6, 2, 5] was the desired result i need something like
foreach ($tree as $j) {
echo $j['id'];
if($j['children']){
}
but how to loop it out to get all the child's? i am not able to catch all the child elements or else i am getting strucked onto an infinite loop is how to get the desired result in php? any suggestions will be really appreciated!