/**
* array_merge() 和 array_replace() 的区别
*/$old=[0=>'this is old 0',2=>'this is old 2','name'=>'this is old name','age'=>'this is old age'];$new=[0=>'this is new 0',1=>'this is new 1','name'=>'this is new name','age'=>'this is new age','sex'=>'男'];array_merge($old,$new);/**
* 输出如下
* array_merge()
* 在数字下标情况下,重排数字下标使其变成有序的,相同key的value值也不会替换
* 在非数字下标情况下,相同key由后者value替换前者value,将后者key不在前者中的key=>value 插入前者之中
*/[0=>'this is old 0',1=>'this is old 2','name'=>'this is new name','age'=>'this is new age',2=>'this is new 0',3=>'this is new 1','sex'=>'男'];array_replace($old,$new);/**
* 输出如下
* 只要key重复由后者value替换前者value
* 添加后者不在前者中存在的数据
*/[0=>'this is new 0',2=>'this is old 2',1=>'this is new 1','name'=>'this is new name','age'=>'this is new age','sex'=>'男'];