匹配第一个和第二个数组关联键。并将第一个数组关联键替换为第二个数组值。信息如下。
1st Array
[
[ ],
[ ],
{
585: {
firsthalf: "0",
secondhalf: "1",
goals: "1",
outcome: ["loss"]
},
625: {
firsthalf: "2",
secondhalf: "2",
goals: "4",
outcome: ["win"]
}
},
{
609: {
firsthalf: "2",
secondhalf: "0",
goals: "2",
outcome: ["win"]
},
625: {
firsthalf: "0",
secondhalf: "1",
goals: "1",
outcome: ["loss"]
}
},
2nd Array
[
{654: "North Geelong Warriors FC"},
{645: "Springvale White Eagles FC"},
{637: "Brunswick City Soccer Club"},
{625: "Melbourne Victory Youth FC"},
{585: "Moreland City FC"},
最终出来应该是这样的
Final Array
[
[ ],
[ ],
{
Moreland City FC: {
firsthalf: "0",
secondhalf: "1",
goals: "1",
outcome: ["loss"]
},
Melbourne Victory Youth FC: {
firsthalf: "2",
secondhalf: "2",
goals: "4",
outcome: ["win"]
}
},
答案 0 :(得分:0)
$newArray = array();
foreach($Array01 as $keys => $values){
foreach($values as $key => $value){
for ($x = 0; $x <= count($array02); $x++) {
if (array_search($key, $array02[$x])){
$newkey = array_search($key,$array02[$x]);
$newArray[] = array($newkey => $value);
}
}
}
}
print_r($$newArray);
这已经解决了。