I'm trying to merge two arrays that have some overlapping results and some that are different, like this:
array(
[0] => array('name' => 'John', 'score' => '9');
[1] => array('name' => 'Pete', 'score' => '2');
[2] => array('name' => 'Eric', 'score' => '7');
)
and
array(
[0] => array('name' => 'Lisa', 'score' => '1');
[1] => array('name' => 'Pete', 'score' => '5');
[2] => array('name' => 'Mary', 'score' => '4');
)
This should result in one array of five (not six) results. The score for Pete should be the sum of his two scores, i.e. '7'.
Is there an easy function for this, or do I have to foreach one (or both?) lists and check them against eachother? I'm not sure how to get started on this, a pointer in the right direction would be appreciated!
edit:
So.. actually both arrays are populated with objects.. Any new ideas?