Answer the question
In order to leave comments, you need to log in
How to implement recursive merging of trees?
How can you recursively merge trees?
Trees look like:
$tree1 = new \ArrayObject(<br>
array(<br>
array('category' => \Shop\Model\Category, 'child' => \ArrayObject([*RECURSIVE*]))<br>
)<br>
);<br>
Answer the question
In order to leave comments, you need to log in
Recursive tree operations are most easily done with a recursive function. Your question is described in such a way that you don’t understand anything, so I’ll give an example of a function that goes through the tree and multiplies each element by 2:
ideone.com/2zVf8C
That is, we make a function that processes one array, and if it has subarrays, we simply call the same function for them. The same approach, it seems to me, will perfectly suit your task.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question