Home / PHP Tips Generated By ChatGPT / Getting the Sum of an Array’s Values in PHP Use array_sum() for an easy way to sum values in an array. Source Code $a = array(2, 4, 6, 8); echo "sum(a) = " . array_sum($a) . "n";