<?php $array = [ ["cust_id" => 1006, "no_of_subs" => 2, "dlv_id" => 1000], ["cust_id" => 1011, "no_of_subs" => 3, "dlv_id" => 1000], ["cust_id" => 1012, "no_of_subs" => 5, "dlv_id" => 1001], ["cust_id" => 1013, "no_of_subs" => 6, "dlv_id" => 1001] ]; foreach ($array as $row) { if (!isset($result[$row["dlv_id"]])) { $result[$row["dlv_id"]] = ["dlv_id" => $row["dlv_id"], "no_of_subs" => $row["no_of_subs"]]; } else { $result[$row["dlv_id"]]["no_of_subs"] += $row["no_of_subs"]; } } var_export(array_values($result));
You have javascript disabled. You will not be able to edit any code.