我有2个这样的数组:
$array1 = array(
array("foo"=>"bar","count"=>"3"),
array("foo2"=>"bar2","count"=>"4"),
array("foo3"=>"bar3","count"=>"2")
);
$array2 = array(
array("foo4"=>"bar","count"=>"3"),
array("foo5"=>"bar2","count"=>"4"),
array("foo6"=>"bar3","count"=>"2")
);
如何将 array2 的第三个元素添加到 array1 中,这样它就可以变成这样:
$array1 = array(
array("foo"=>"bar","count"=>"3"),
array("foo2"=>"bar2","count"=>"4"),
array("foo3"=>"bar3","count"=>"2"),
array("foo6"=>"bar3","count"=>"2")
);
我试过做$array1 += $array2[2];
,但它不起作用。它只是将键添加array("foo6"=>"bar3","count"=>"2")
到 array1 而不是将其作为数组添加到$array1
你能帮帮我吗?