diff --git a/reference/array/functions/array-merge.xml b/reference/array/functions/array-merge.xml index 46fc9dcec3..e6f6be554c 100644 --- a/reference/array/functions/array-merge.xml +++ b/reference/array/functions/array-merge.xml @@ -1,21 +1,21 @@ - + array_merge - Merge two or more arrays + Merge one or more arrays Description arrayarray_merge arrayarray1 - arrayarray2 + arrayarray2 array... - array_merge merges the elements of two or + array_merge merges the elements of one or more arrays together so that the values of one are appended to the end of the previous one. It returns the resulting array. @@ -26,6 +26,11 @@ role="strong">not overwrite the original value, but will be appended. + + If only one array is given and the array is numerically indexed, the + keys get reindexed in a continuous way. For associative arrays, duplicate + entries will be merged into the last one. See example three for details. + <function>array_merge</function> example @@ -103,6 +108,43 @@ Array ( [1] => data ) +]]> + + + + <function>array_merge</function> example + + "jay", 1 => "bob", 2 => "randal", 3 => "dante"); +$array_two = array("jay" => "bob", "randal" => "dante", "jay" => "jason"); + +unset($array_one[2]); + +$result_one = array_merge($array_one); +$result_two = array_merge($array_two); + +print_r($result_one); +print_r($result_two); +?> +]]> + + + The output is: + + + jay + [1] => bob + [2] => dante +) +Array +( + [jay] => jason + [randal] => dante +) ]]>