时间:2021-07-01 10:21:17 帮助过:24人阅读
代码如下:
$a = array('a','b');
$b = array('c', 'd');
$c = $a + $b;
var_dump($a);
var_dump(array_merge($a, $b));
$a = array(0 => 'a', 1 => 'b');
$b = array(0 => 'c', 1 => 'b');
$c = $a + $b;
var_dump($c);
var_dump(array_merge($a, $b));
$a = array('a', 'b');
$b = array('0' => 'c', 1 => 'b');
$c = $a + $b;
var_dump($c);
var_dump(array_merge($a, $b));
$a = array(0 => 'a', 1 => 'b');
$b = array('0' => 'c', '1' => 'b');
$c = $a + $b;
var_dump($c);
var_dump(array_merge($a, $b));
代码如下:
array
0 => string 'a' (length=1)
1 => string 'b' (length=1)
2 => string 'c' (length=1)
3 => string 'd' (length=1)
array
0 => string 'a' (length=1)
1 => string 'b' (length=1)
array
0 => string 'a' (length=1)
1 => string 'b' (length=1)
2 => string 'c' (length=1)
3 => string 'b' (length=1)
array
0 => string 'a' (length=1)
1 => string 'b' (length=1)
array
0 => string 'a' (length=1)
1 => string 'b' (length=1)
2 => string 'c' (length=1)
3 => string 'b' (length=1)
array
0 => string 'a' (length=1)
1 => string 'b' (length=1)
array
0 => string 'a' (length=1)
1 => string 'b' (length=1)
2 => string 'c' (length=1)
3 => string 'b' (length=1)
以上就介绍了array_merge PHP合并数组+与array_merge的区别分析,包括了array_merge方面的内容,希望对PHP教程有兴趣的朋友有所帮助。