Go to navigation

On the uselessness of array_merge_recursive()

Hugo Wetterberg - 8 januari

I guess that most people have run afoul of the monstrosity that is array_merge_recursive(). In short a merge of array('a'=>2, 'b'=>3) and array('b'=>4) gives you array('a'=>2,'b'=>array(3,4)) which isn't the result that one would expect.

So, as usual, I've created a gist that outlines the problem and gives a more sensible alternative.

http://gist.github.com/271920