[Solved] Sum up array values [closed]


Because $product refers to each iteration of $output["PriceInformation"]["PriceDetails"]["Price"], you can’t sum the entire array like this. The best way to do it would be to add it to a variable as you go:

$your_sum = 0;
foreach($output as $value) {
    $your_sum += $value['PriceInformation']['PriceDetails']['Price'];
}
echo 'Sum: ' . $your_sum;

1

solved Sum up array values [closed]