1<?php
2
3$array1 = array('key1' => 'test1', 'key2' => 'test2');
4$array2 = array('key3' => 'test3', 'key4' => 'test4');
5
6$resultArray = array_merge($array1, $array2);
7
8// If you have numeric or numeric like keys, array_merge will
9// reset the keys to 0 and start numbering from there
10
11$resultArray = $array1 + $array2;
12
13// Using the addition operator will allow you to preserve your keys,
14// however any duplicate keys will be ignored.
1<?php
2$a1=array("red","green");
3$a2=array("blue","yellow");
4print_r(array_merge($a1,$a2));
5?>
1
2<?php
3$array1 = array("color" => "red", 2, 4);
4$array2 = array("a", "b", "color" => "green", "shape" => "trapezoid", 4);
5$resultado = array_merge($array1, $array2);
6print_r($resultado);
7?>
8
9
1<?php
2$array1 = array(1,"dos",3,4,"cinco",9);
3$array2 = array(1,"hola",3,"adios",5,6);
4//muestro los arrays
5var_export ($array1);
6var_export ($array2);
7//uno los arrays y muestro el array resultante
8$array_resultante= array_merge($array1,$array2);
9var_export ($array_resultante);
10?>
1Combina los elementos de uno o más arrays juntándolos de modo que los valores de uno se anexan al final del anterior. Retorna el array resultante.