I take care to know how to go through a multidimensional array in php and get its values. The arrangement corresponds to a multilevel menu.
In the Array of the image I need to extract the ID of the array, and in case an ID is inside a children, know what is its parent ID, since not all the Items have children. I'll give an example below.
Here is the same arrangement in code.
[
[
"id"=>1,
"children"=>[
[
"id"=>2,
"children"=>[
[
"id"=>3,
"children"=>[
["id"=>4]
]
],
[
"id"=>5
]
]
]
]
],
[
"id"=>6,
"children"=>[
[
"id"=>7,
"children"=>[
[
"id"=>8,
"children"=>[
[
"id"=>9
]
]
],
[
"id"=>9
]
]
]
]
]
];
For example
[ ['id'=>1, 'parent' => null], ['id'=>2, 'parent' => 1], ['id'=>3, 'parent' => 2] ]