Hi,
I am trying to recursively build another array based on the one I get back from our CRM api. The array I get back looks like this:
[1] => stdClass Object
(
[description] => Description Text
[label] => Product
[name] => Product
[sobject] => KnowledgeArticleVersion
[topCategories] => stdClass Object
(
[childCategories] => Array
(
[0] => stdClass Object
(
[childCategories] => Array
(
[0] => stdClass Object
(
[childCategories] => Array
(
[0] => stdClass Object
(
[label] => Apple
[name] => Apple
)
[1] => stdClass Object
(
[label] => Orange
[name] => Orange
)
[2] => stdClass Object
(
[label] => lemon
[name] => lemon
)
)
[label] => Templates
[name] => Templates
)
[1] => stdClass Object
(
[label] => Connector
[name] => Connector
)
[2] => stdClass Object
(
[label] => AeroView
[name] => AeroView
)
)
[label] => AeroWare
[name] => AeroWare
)
[1] => stdClass Object
(
[label] => BackOffice
[name] => BackOffice
)
[2] => stdClass Object
(
[label] => OutWare
[name] => OutWare
)
[3] => stdClass Object
(
[childCategories] => Array
(
[0] => stdClass Object
(
[label] => ERA
[name] => ERA
)
[1] => stdClass Object
(
[label] => Kairos
[name] => Kairos
)
)
[label] => InWare
[name] => InWare
)
)
[label] => All
[name] => All
)
)
The child categories could be any level deep. I would like put it in an array something like this:
Array
(
[label] => Cat 1
[level] => 0
[children] => Array
(
[label] => Sub Cat 1
[level] => 1
[children] => Array
(
[label] => Sub Sub Cat 1
[level] => 2
)
)
)
I have tried so many things but I just can't get it right. Any assistance would be greatly appreciated.
Thanks
Peter