我们首先给出两个数组
复制代码 代码如下:
$r = array(1,2,3,4,5,6);
$e = array(7,8,9,10);
?>
复制代码 代码如下:
print_r($r+e); // 输出Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5 [5] => 6 )
print "
";
print_r(array_merge($r,$e)); // 输出Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5 [5] => 6 [6] => 7 [7] => 8 [8] => 9 )
?>
复制代码 代码如下:
$r = array('r'=>1,2,3,4,5,6);
$e = array('r'=>7,8,9,10);
?>
复制代码 代码如下:
print_r($r+e); // 输出Array ( [r] => 1 [0] => 2 [1] => 3 [2] => 4 [3] => 5 [4] => 6 )
print "
";
print_r(array_merge($r,$e)); // 输出Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5 [5] => 6 [6] => 7 [7] => 8 [8] => 9 )
?>