I have two arrays in php, both have a date value with 7 days. The same in each. The rest of the content of the array differs. They look a little like this:
Array #1:
[0]
[date] => 2012-05-01
[value 1] => 3
Array #2:
[0]
[date] => 2012-05-01
[value 2] => 3
I'd like to merge them to get this:
[0]
[date] => 2012-05-01
[value 1] => 3
[value 2] => 3
Right now I'm using this slop:
$i = 0;
$full_array = array();
foreach ($array_1 as $a) {
foreach ($array_2 as $b) {
if ($a['date'] == $b['date']) {
$full_array[$i] = $a;
$full_array[$i] += $b;
$i++;
}
}
}
I can turn that guy into a function but before I do I figured I'd check to see if there was a better way. Thanks!