This article mainly introduces how to add two arrays in php, and analyzes the array operator + in php with examples. The usage skills have certain reference value. Friends in need can refer to it
The example in this article describes how to add two arrays in PHP. Share it with everyone for your reference. The details are as follows:
Example 1:
?
3 4
5
6
|
$arr1 = array("a"=>"Chaoyang District","b"=>"Haidian District");
$arr2 = array("h"=>"Xicheng District","a"=>"Dongcheng District","b"=>"Fengtai District");
$arr = $arr1 + $arr2;
"; print_r($arr); |
1 2 3 4 5 6 |
Array ( [h] => 西城区 [a] => 东城区 [b] => 丰台区 ) |
?
1 2 3 4
|
Array
(
[a] => Chaoyang District
[b] => Haidian District
[h] => Xicheng District
) |
1 2 3 4 5 6 7 |
<🎜>$arr1 = array("a"=>"Chaoyang District","b"=>"Haidian District");
$arr2 = array("h"=>"Xicheng District","a"=>"Dongcheng District","b"=>"Fengtai District");
$arr = $arr2 + $arr1;
echo ""; print_r($arr); ?> |
1 2 3 4 5 6 | Array ( [h] => Xicheng District [a] => Dongcheng District [b] => Fengtai District ) |