I have a bunch of objects tiered in an array, and want to recursively loop through them with PHP to add their corresponding tiers. How can I do that?
NOTE: The structure of the array could go much deeper than shown.
Array
(
[0] => stdClass Object //should be tier 1
(
[name] => Object name
[children] => Array
(
[0] => stdClass Object //should be tier 2
(
[name] => Object name
[children] => Array
(
[0] => stdClass Object //should be tier 3
(
[name] => Object name
[children] => Array
(
)
)
[1] => stdClass Object //should be tier 3
(
[name] => Object name
[children] => Array
(
)
)
)
)
[1] => stdClass Object //should be tier 2
(
[name] => Object name
[children] => Array
(
[0] => stdClass Object //should be tier 3
(
[name] => Object name
[children] => Array
(
)
)
)
)
)
)
[1] => stdClass Object //should be tier 1
(
[name] => Object name
[children] => Array
(
)
)
)