<?php
$array=[
['NDC_ItemType'=>'Night','NDC_Item'=>'Night','NDC_Quantity'=>1],
['NDC_ItemType'=>'Night','NDC_Item'=>'Night','NDC_Quantity'=>1],
['NDC_ItemType'=>'Night','NDC_Item'=>'Night','NDC_Quantity'=>1],
['NDC_ItemType'=>'Night','NDC_Item'=>'Night','NDC_Quantity'=>1],
['NDC_ItemType'=>'Night','NDC_Item'=>'Night','NDC_Quantity'=>1],
['NDC_ItemType'=>'Item','NDC_Item'=>'Hot-Dog','NDC_Quantity'=>5]
];
foreach($array as $row){
if(!isset($result[$row['NDC_ItemType']])){
$result[$row['NDC_ItemType']]=$row['NDC_Quantity'];
}else{
$result[$row['NDC_ItemType']]+=$row['NDC_Quantity'];
}
}
var_export($result);
preferences:
26.12 ms | 402 KiB | 5 Q