I have an array in the format:
array (
'1' => array (
'id' => '2',
'qty' => '4'
),
'2' => array (
'id' => '1',
'qty' => '1'
),
'3' => array (
'id' => '2',
'qty' => '3'
),
'4' => array (
'id' => '4',
'qty' => '6'
)
);
And want to find all duplicates of the column 'id', and to combine them into one (adding the values for 'qty' together).
Is there a better way to do this than a two foreach's? - it seems a bit too brute-forcey for me.