码迷,mamicode.com
首页 > 编程语言 > 详细

PHP 数组相加 和 数组合并array_merge

时间:2019-03-04 19:16:13      阅读:283      评论:0      收藏:0      [点我收藏+]

标签:var   合并   pytho   array   php   数组   python   c++   die   

$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++" }

PHP 数组相加 和 数组合并array_merge

标签:var   合并   pytho   array   php   数组   python   c++   die   

原文地址:https://www.cnblogs.com/chxrs/p/10472341.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!