合并具有一个公共元素的两个数组php

时间:2014-10-26 16:08:33

标签: php mysql arrays

我必须得到这样的数组:

array(3){[0] => array(3){[“name”] => string(4)“Luke”[“surname”] => string(3)“Fox”[“age”] => 18} [1] => {[“name”] => string(4)“Paul”[“surname”] => string(3)“Red”[“age”] => 34} {[“name”] => string(5)“Marie”[“surname”] => string(8)“Coldfear”[“age”] => 23}}

我有两个包含查询记录的数组

$ records = array(3){[0] => array(3){[“name”] => string(4)“Luke”[“age”] => 18} [1] => {[“name”] => string(4)“Paul”[“age”] => 34} {[“name”] => string(5)“Marie”[“age”] => 23}}

$ rows = array(3){[0] => array(3){[“name”] => string(4)“Luke”[“surname”] => string(3)“Fox”} [1] => {[“name”] => string(4)“Paul”[“surname”] => string(3)“Red”} {[“name”] => string(5)“Marie”[“surname”] => string(8)“Coldfear”}

正如你在两个数组中看到的那样,关键字“name”存在,所以我想将数组与它合并,我该怎么办?

0 个答案:

没有答案