I have a object - let's call it $node
.
This object has a property called $node->children
, which essentially returns a array of child objects (nodes), in the form of node_id => NodeObject
:
Array
[1] => Node object
[2] => Node object
[3] => Node object
...
These child objects are of the same type, so they too have the same property...
How can I gather all the child and grand-child node IDs for a given node?
I need to somehow walk trough the all child nodes, but I don't know how. Right now I'm stuck with array_keys($children)
, but it only gets me the 1st level children.
Not sure if it matters but this property comes from a magic __get method, I can't see its contents with print_r ...