这是我的两个数组:
$array1 =( [0] => Array ( [row_id] => 237 [comment] => 'hello0' )
[1] => Array ( [row_id] => 5 [comment] => 'hello1' )
[2] => Array ( [row_id] => 6 [comment] => 'hello2' ) );
$array2= ( [0] => Array ( [row_id] => 5 [vote] => 1 )
[1] => Array ( [row_id] => 7 [vote] => 1 )
[2] => Array ( [row_id] => 237 [vote] => 0 ) );
我想匹配$array1
并添加$array2
的键/值对
到 $array1 哪里[row_id]
$array2
[vote]
$array1[row_id]=$array2[row_id]
这就是我希望输出的方式:
$array1 =( [0] => Array ( [row_id] => 237 [comment] => 'hello0' [vote] => 0 )
[1] => Array ( [row_id] => 5 [comment] => 'hello1' [vote] => 1 )
[2] => Array ( [row_id] => 6 [comment] => 'hello2' [vote] => 1 ) );
我相信有很多方法可以做到这一点,所以对最快计算的想法也将不胜感激!