PHP comes with a convenient function for merging an array by its index, called array_merge . Unfortunately there isn't a straightforward function for merging an array by values.
Here is an implementation, which works if the indexes are irrelevant. Since it relies on native function's it is still faster than a solution with scripted-logic. I also discovered a curiosity/"bug" in the PHP parser:
Here is an implementation, which works if the indexes are irrelevant. Since it relies on native function's it is still faster than a solution with scripted-logic. I also discovered a curiosity/"bug" in the PHP parser: