标签:style blog color os ar sp div on log
1:数组可以相加,但是键名不能相等,要不然会被覆盖;
$x = array(‘a‘,‘b‘); $y = array(3=>‘c‘,4=>‘d‘); $z = $x+$y; print_r($z);
浏览器显示结果为:
Array
(
[0] => a
[1] => b
[3] => c
[4] => d
)
2:用array_merge()函数;
1 $x = array(‘a‘,‘b‘);
2 $y = array(3=>‘c‘,4=>‘d‘);
3
4 $z = array_merge($x,$y);
5 print_r($z);
显示结果和1是一样的:
1 Array 2 ( 3 [0] => a 4 [1] => b 5 [2] => c 6 [3] => d 7 )
标签:style blog color os ar sp div on log
原文地址:http://www.cnblogs.com/a2762/p/4026638.html