I have an array:
Array
(
[0] => Array
(
[qty] => 2
[id] => 1
[name] => Name 1
[sku] =>
$result = array();
foreach ($input as $subarray) {
$id = $subarray['id'];
if (isset($result[$id])) { // Same ID
$result[$id]['qty'] += $subarray['qty']; // Add quantities
} else {
$result[$id] = $subarray; // New ID, put in results
}
}
$result = array_values($result); // Convert from associative array to indexed