I want to sum the value of one key (qty) if has the same ID of n numbers of arrays inside an array, in this example I have only 2 arrays but I could have 1000
$a = array(
array(
"id"=>1,
"qty"=>2
),
array(
"id"=>1,
"qty"=>4
)
...n arrays
);
I want the result like this...
$b = array(
array(
"id"=>1,
"qty"=>6
));
I want a function to pass variable $a with n numbers of arrays and returned $b. Thank you