Skip to content
Advertisement

Merge multi dimensional array preserving keys not working

I have following two arrays

JavaScript

I want to merge two arrays so that the final array looks like

JavaScript

I have used the following approaches but it’s not working:

JavaScript

I want to achieve the final array with the native function (minimal code) if possible.

Advertisement

Answer

Finally found the solution using array_replace_recursive

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement