<?php $array = array(1, 2, 3, 4); $sum = 0; foreach($array as $elem) { $sum = $sum + $elem; } print($sum); ?>
<?php $array = [1,2,3,4,5,6,7,8,9,10]; echo array_sum($array); ?>
$s=0; foreach ($array as $v) {$s+=$v;}