Elegant way to aggregate multi-dimensional array by index key
- by Stephen J. Fuhry
How can I recursively find the total value of all children of an array that looks something like this?
[0] => Array
(
[value] => ? // 8590.25 + 200.5 + 22.4
[children] => Array
(
[0] => Array
(
[value] => ? // 8590.25 + 200.5
[children] => Array
(
[0] => Array
(
[value] => 8590.25 // leaf node
)
[1] => Array
(
[value] => 200.05 // leaf node
)
)
)
[1] => Array
(
[value] => 22.4 // leaf node
)
)
)