Home >php教程 >php手册 >php array_merge下进行数组合并的代码

php array_merge下进行数组合并的代码

WBOY
WBOYOriginal
2016-06-13 12:28:101026browse

如 

$array3=array("性别"=>"男","姓名"=>"不是女人"); 
$array4=array("性别"=>"不知道","长相"=>"很帅"); 

哪么,合并之后,后者将会覆盖前者,这样合并之后就变成了 

Array ( [性别] => 不知道 [姓名] => 不是女人 [长相] => 很帅 ) 



数字型键名,或自动赋值键名,则不会产生覆盖, 

如 

$array1=array(1,2,3,4,5,6,7); 
$array2=array(1,7,8,9,10); 

合并之后,为 

Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5 [5] => 6 [6] => 7 [7] => 1 [8] => 7 [9] => 8 [10] => 9 [11] => 10 )

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn