Let's start with a two array
Copy CodeThe code is as follows:
$r = Array (1,2,3,4,5,6);
$e = Array (7,8,9,10);
?>
Now let's use the Array_merge and the plus sign to why these two arrays
Copy the Code code as follows:
Print_r ($r +e); Output Array ([0] = 1 [1] = 2 [2] = 3 [3] = 4 [4] = 5 [5] = 6)
Print "
";
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)
?>
It can be seen from here that the values in an array with Array_merge are appended to the previous array. Returns an array that is the result of if the array contains numeric key names, subsequent values will not overwrite the original values, but are appended to the back. However, using the plus sign to merge the array if the key name is the same, take the first occurrence of the array value, followed by the directly ignored
Let's change the array given in the previous
Copy the Code code as follows:
$r = Array (' R ' =>1,2,3,4,5,6);
$e = Array (' r '= = 7,8,9,10);
?>
Copy the Code code as follows:
Print_r ($r +e); Output array ([r] = 1 [0] = 2 [1] = 3 [2] = 4 [3] = 5 [4] = 6)
Print "
";
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)
?>
It can be seen from here that the values in an array with Array_merge are appended to the previous array. If the non-numeric key name is the same, the value of the subsequent array overrides the value of the preceding array. However, using the plus sign to merge the array if the key name is the same, take the first occurrence of the array value, followed by the directly ignored
http://www.bkjia.com/PHPjc/744324.html www.bkjia.com true http://www.bkjia.com/PHPjc/744324.html techarticle We first give two array copy code code as follows: PHP $r = Array (1,2,3,4,5,6), $e = Array (7,8,9,10), the following we use Array_merge and the plus sign to why these two arrays copy code ...