$arr1 = array("a"=>"PHP","b"=>"java","python");
$arr2 = array("c" =>"ruby","d" => "c++","go","a"=> "swift");
$arr3 = array_merge($arr1,$arr2);
$arr4 = $arr1 + $arr2;
var_dump($arr3);
var_dump($arr4);die;
输出:
array(6) { ["a"]=> string(5) "swift" ["b"]=> string(4) "java" [0]=> string(6) "python" ["c"]=> string(4) "ruby" ["d"]=> string(3) "c++" [1]=> string(2) "go" }
array(5) { ["a"]=> string(3) "PHP" ["b"]=> string(4) "java" [0]=> string(6) "python" ["c"]=> string(4) "ruby" ["d"]=> string(3) "c++" }
标签:java,string,python,c++,merge,数组,arr1,array
来源: https://www.cnblogs.com/chxrs/p/10472341.html