I have two arrays: $arr1
and $arr2
. The two arrays have equal keys. I am merging the two arrays with duplicate keys. My output should show the duplicate keys with their corresponding values, for example
the key 22 exists and contains values 333,673,434
Below is my current code:
<?
$result = array();
foreach ($arr1 as $i => $key)
{
$result[] = array($key => $arr2[$i]);
}
print_r($result);
?>
Result as below
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
)
}