需要合并数组1与数组2,数组2的只要有值就覆盖数组1的值,合并结果如图[3],请请请教各位大神看看
说明:数组1结构固定的,数组2结构不固定有时多几个字段 有时少。
数组1
$arr1 = Array(
0 => Array('name' => '山东东营','Nab' =>12,'Nac' => '','Nad' => '','Nae' => '','Nag' => '','Nak' => '','Nao' => '','Naw' => '','Naz' =>'','province' => '海南省','Naaa' => 12),
1 => Array('name' => '天津','Nab' => 3,'Nac' => '','Nad' => '','Nae' => '','Nag' => '','Nak' => '','Nao' => '','Naw' => '','Naz' =>'','province' => '湖北省','Naaa' => 2),
2 => Array('name' => '洛阳','Nab' => 3,'Nac' => '','Nad' => '','Nae' => '','Nag' => '','Nak' => '','Nao' => '','Naw' => '','Naz' =>'','province' => '湖北省','Naaa' => 2)
...
);
$arr2 = Array(
0 => Array('name' => '山东东营','Nac' => 1,'Nad' => 262,'Nae' => 1,'Nag' => 1,'Nak' => 524,'Nao' => 2,'Naw' => 2,'Naz' => 1),
1 => Array('name' => '天津','Nac' => 0,'Nad' =>'' ,'Nae' => 0,'Nao' => 0),
2 => Array('name' => '洛阳','Nac' => 1,'Nad' => 342,'Nae' => 1,'Nag' => 1,'Nak' => 342,'Nao' => 1)
...
);
问题补充
图[1] 基本结构,图[2] 数据,图[3] 最终结果
如图:
$数组3 = array_merge($数组1, $数组2);