Home »

What is difference between array_combine and array_merge?

Question ListCategory: PHPWhat is difference between array_combine and array_merge?
denielshakespeare5 author asked 1 year ago
2 Answers
milleranthony7 author answered 10 months ago

array_merge merges the elements of one or more arrays. array_combine Creates an array by using one array as its keys and another for its values.

jessica537 author answered 10 months ago

“array_combine give an array by combining two arrays($keyArray, $valueArray) and both $keyArray & $valueArray must have same number of elements. $keyArrays become keys of returning Array, $valueArray become values of returning Arrays.

array_merge gives an array by merging two array ($array1, $array2) and both can have different number of elements. $array1 and $array2 are added in returning array.”

Please login or Register to Submit Answer