This article mainly introduces two methods of the PHP array merging, and also tells the difference between using the plus sign and using the Array_merge to merge the array, the need friend can refer to the following
We first give two arrays code as follows: <?php $r = array (1,2,3,4,5,6); $e = array (7,8,9,10); ?> We're going to use the Array_merge and the plus sign here. The two arrays code are as follows: <?php Print_r ($r +e); Output <span style= "FONT-FAMILY:SIMSUN;FONT-SIZE:16PX; ">array ([0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5 [5] => 6) </span> print" <br /> "; Print_r (Array_merge ($r, $e)); Output <span style= "FONT-FAMILY:SIMSUN;FONT-SIZE:16PX; ">array ([0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5 [5] => 6 [6] => 7 [7] => 8 [8] => 9) </span> ?> From here you can see that the value in an array of Array_merge merged arrays is appended to the back of the previous array. Returns an array as a result if the array contains a numeric key name, the subsequent value will not overwrite the original value, but append to the back. However, with the plus sign to merge the array if the key name is the same, then the first occurrence of the array value, the following directly ignore the below we'll change the array code as follows: <?php $r = Array (' r ' = >1,2,3,4,5,6); $e = Array (<span style= "Background-color:rgb" (245, 250, 255); "> ' R ' =></span>7,8,9,10); ?> code is as follows: <?php Print_r ($r +e); Output array ([r] => 1 [0] => 2 [1] => 3 [2] => 4 [3] => 5 [4] => 6) print "<br/>"; Print_r (Array_merge ($r, $e)); Output array ([0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5 [5] => 6 [6] => 7 [7] => 8 [8] => 9) ?> From here you can see that the value in an array of Array_merge merged arrays is appended to the back of the previous array. If the name of the Non-numeric key is the same, the value of the following array overrides the value of the preceding array. However, with the plus sign to merge the array if the key name is the same, then the first occurrence of the array value, the following is directly ignored