该方法如果只给了一个数组并且该数组是数字索引的,则键名会以连续方式重新索引。所以只能适用于数字索引。
<?php
$arr = array(
1 => 'apple',
3 => 'banana',
5 => 'orange'
);
print_r(array_merge($arr));
$arr1 = array(
'name' => 'jerry',
'age' => 16,
'height' => '18cm'
);
print_r(array_merge($arr1));
输出结果:
[root@localhost php]# php array.php
Array
(
[0] => apple
[1] => banana
[2] => orange
)
Array
(
[name] => jerry
[age] => 16
[height] => 18cm
)