I am trying to combine two arrays that have some overlapping results and some have different results, for example:
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 will result in one array of five (not six) results. The score for Pet should be the sum of his two points, i.e. "7".
Is there a simple function for this, or do I need to skip one (or both?) Lists and check them against eachother? I'm not sure how to start from this, a pointer in the right direction would be appreciated!
Edit
So, in fact, both arrays are filled with objects. Any new ideas?
source
share