Difference between array_merge() and array_merge_recursive() Functions
array_merge() Functions | array_merge_recursive() Functions |
---|---|
This function is used to combine two or more arrays into one single array | This function is used to combine multiple arrays such that value of one array is appended to end of last array |
This function is used when elements of array has different keys | This function is used when elements of array has same keys |
Syntax: array_merge($array1, $array2, $array3…..); | Syntax: array_merge_recursive($array1, $array2, $array3…..); |
What is the differences between array_merge() and array_merge_recursive() functions in PHP ?
In this article, we will see the array_merge() and array_merge_recursive() functions, along with understanding their basic implementation, & the differences between them.
Both the array_merge() Function and array_merge_recursive() function can be used to combine multiple arrays into a single array.
Table of Content
- PHP array_merge() Function
- PHP array_merge_recursive() Function
- Difference between array_merge() and array_merge_recursive() Functions