I have two n-dimensional arrays which I would like to merge. I have already reviewed this question, however, it is only good for merging two dimensional arrays. I am trying to accomplish the same thing, except with two n-dimensional arrays.
So, for example:
Array 1:
Array (
[''] => 'ID One'
['foo'] => Array (
[''] => 'ID Two'
['bar'] => 'ID Three'
)
)
Array 2:
Array (
['foo'] => Array (
['bar'] => Array (
['baz'] => 'ID Four'
)
)
['bax'] => 'ID Five'
)
Desired Array Result:
Array (
[''] => 'ID One'
['foo'] => Array (
[''] => 'ID Two'
['bar'] => Array (
[''] => 'ID Three'
['baz'] => 'ID Four'
)
)
['bax'] => 'ID Five'
)
Although this is a demonstration of what I am trying to achieve, when it is being used for some web apps, it is entirely possible that it will have 10, perhaps even 15 nested arrays. So, how can Array 1 and Array 2 be merged to form the Desired Array Result?