How To Merge Arrays Into One Array In PHP ?

March 12, 2019

In this Tutorial We are Learning How To Merge Arrays Into One Array In PHP ? You have easily merge array using array_merge() function. This Function is Useful to merge two or more arrays into one array.

array_merge()

array_merge() is built in function in php. The array_merge() function merges one or more arrays into one array.

Input

Output

Above is Example of Merge Two Array using array_merge() function in php.

If two or more array have same key. The last one Overrides the Others.

You have to use the array_merge_recursive() function is when two or more arrays have a same key. You need values as array instead of override the Keys.

Karan Suthar

Surat, India

I'm Karan, the creator Behind the KTechBlog. I write Blogs in my Free Time. I ❤ to learn new Technologies and Share with Others. I'm Trying best effort to make KTechBlog useful for Everyone.