I have this array :
$data = Array
(
[1] => Array
(
[id] => '52040344'
[outcome] => 0
[names] => Array
(
[name_eng] => 'this is a name 2'
)
)
[2] => Array
(
[id] => 54030157
[outcome] => 1108541
[names] => Array
(
[name_eng] => 'this is a name 1'
)
)
[3] => Array
(
[id] => '54030157
[outcome] => '109635'
[names] => Array
(
[name_eng] => 'this is a name 1'
)
)
)
i want to to return an array with the sum of all outcome having the same id, knowing that if they have same id, they have same name.
so i can get
array (
[0] => array( 'id' => '54030157', 'outcome' => 'sum of outcome', 'name' => 'this is name 1' ),
[1] => array( 'id' => '52040344', 'outcome' => 'sum of outcome', 'name' => 'this is name 2' )
)
how can i get this done ??.
here is what i have tried so far :
public function process($data){
$outputArray = array();
foreach ($data as $key => $value) {
}
return $outputArray;
}
any help would be appreciated