Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

PHP sum array values by key

$sumArray = array();

foreach ($myArray as $k=>$subArray) {
  foreach ($subArray as $id=>$value) {
    $sumArray[$id]+=$value;
  }
}

print_r($sumArray);
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #PHP #sum #array #values #key
ADD COMMENT
Topic
Name
5+1 =