我想要组合两个数组,但困难的部分是我必须在条件满足时才结合两个键。
$array1 = array(
10 => array('name' => 'I am testing', 'id' => 1),
20 => array('name' => 'This is a sample', 'id' => 2),
30 => array('name' => 'I am using stackoverflow', 'id' => 3)
);
$array2 = array(
100 => array('name' => 'I am testing', 'id' => 7),
200 => array('name' => 'This is second array', 'id' => 8)
);
$expectedarray1 = array(
0 => array(10 => array('name' => 'I am testing', 'id' => 1) , 100 =>array('name' => 'I am testing', 'id' => 7)),
1 => array(20 => array('name' => 'This is a sample', 'id' => 2)),
2 => array(30 => array('name' => 'I am using stackoverflow', 'id' => 3)),
3 => array(200 => array('name' => 'This is second array', 'id' => 8)),
);
或
$expectedarray1 = array(
[0] => array(10 => array('name' => 'I am testing', 'id' => 1) , 100 array('name' => 'I am testing', 'id' => 7)),
);
这可能吗?我知道我可以循环但是我有一个巨大的阵列一个是500而另一个是400所以寻找更好的解决方案。
提前感谢大家。