Skip to content

The different Between array_merge and array_combine in php

  • by

The array_merge function is a built-in function of php. This function is used to combine key and value of two array or more arrays. Between array_merge and array_combine in php.

I have been working at job and the interesting thing is when working with other people’s code  you often learn a pile of material you already didn’t know. A couple of weeks ago I came across a way to merge arrays in PHP with operator, instead of using the array functions (array_merge) so see.

Different Between array_merge and array_combine in php

In this article we will discuss about two function of php (“1”). array_merge(); (“2”). array_combine(). And i will tell you what is the different between array_combine and array_merge in php.


It is used to creates a new array by using the key of a array as keys and using the value of another array as values.



$array1 = array('key1', 'key2', 'key3');

$array2 = array('', 'The Whole Blogs', 'wholeblogs');

$new_array = array_combine($array1, $array2);




Array([key1]  =>[key2]    => The Whole Blogs[key2]    =>wholeblogs)


It merges one or more than one array such as that the value of one array appended at the end of the first array. If the arrays have the same string keys, then the next value overrides the previous value for that key.

Read more: array_merge VS array_combine


$a1=array("United Kingdom","USA");


Array ( [0] =>[1] => USA[2] => Pakistan[3] => Canada)

array_merge and array_combine

Leave a Reply

Your email address will not be published. Required fields are marked *