I have a multidimensional array that looks like this
[0] => Array
(
[recordId] => 5
[leaf] => 1
[children] => Array
(
[0] => Array
(
[recordId] => 6
[leaf] => 1
[children] => Array
(
[0] => Array
(
[recordId] => 7
[leaf] => 1
)
)
)
[1] => Array
(
[recordId] => 8
[leaf] => 1
[children] => Array
(
[0] => Array
(
[recordId] => 9
[leaf] => 1
)
[1] => Array
(
[recordId] => 10
[leaf] => 1
)
)
)
)
)
Each node has a 'leaf' key that is TRUE by default and has a 'children' array if there are further nodes down.
I need to set the 'leaf' key value to FALSE if there is a 'children' array contained in the node. That way only final nodes have the leaf = TRUE designation.
I've tried searching but can't find code to do what I need and I can't wrap my head around the recursive function that I believe is needed.
Any ideas how I could accomplish this in PHP?
Thanks for the help.