I have a ArrayObject structure that is quite complex to output, it can/and consists of multiple levels of relationship e.g. Parent -> Child -> Children -> Child etc.
Structures like this are quite complex to work with when using a foreach, for or while loop. I've looked into SPL Iterators and I think this can be used. I'm a bit unfamiliar with the whole concept so any advice on looping over multiple levels would be wel开发者_如何转开发l received.
Thanks
In my experience you should just use a recursive function call.
By that I mean you simple make a function that does whatever you need, but have a while loop at the end of the function that loops through the children and calls the function again on each child. This way you fire the function on every child of the original object.
精彩评论