我有两个数组:$arr1
和$arr2
. 这两个数组具有相同的键。我正在使用重复键合并两个数组。例如,我的输出应显示具有相应值的重复键
the key 22 exists and contains values 333,673,434
以下是我当前的代码:
<?
$result = array();
foreach ($arr1 as $i => $key)
{
$result[] = array($key => $arr2[$i]);
}
print_r($result);
?>
结果如下
Array
(
[0] => Array
(
[22] => 333
)
[1] => Array
(
[22] => 673
)
[2] => Array
(
[22] => 434
)
[3] => Array
(
[29] => 67
)?>
[4] => Array
(
[29] => 98
)
[5] => Array
(
[29] => 656
)
[6] => Array
(
[28] => 12
)
}