sum array value code example
Example 1: php sum array elements
<?php
$a=array(5,15,25);
echo array_sum($a);
?>
Example 2: arrays.sum
int sum = Arrays.stream("1 2 3 4".split("\\s+")).mapToInt(Integer::parseInt).sum();
Example 3: sum of an array
const sum = (...args) => args.reduce((a, b) => a + b, 0);
console.log(sum(1,2,3)); // returns 6