Move element of array to deepest match - PHP
I need to {-code-3}onvert this stru{-code-3}ture:
<{-code-3}ode>{-{-code-3}ode-1} {-code-3}ode>
I need to get the order into:
<{-code-3}ode>{-{-code-3}ode-2} {-code-3}ode>
I am trying to follow this answer but that doesnt seem to move elements up and down the levels of the obje{-code-3}t.
It needs to be appended on to the deepest level (so if <{-code-3}ode>{-code-3}{-code-3}ode> was under <{-code-3}ode>d{-code-3}ode> and not <{-code-3}ode>b{-code-3}ode>, it must append there and not under <{-code-3}ode>b{-code-3}ode>.
What is the best way to do this?