Source Code:
(back to article)
<?php function foo(array $arr) { $sum = array_sum($arr); // calculate the sum of the array return "The sum of the array is: $sum"; } // Example usage: $array = [1, 2, 3, 4, 5]; echo foo($array); // outputs "The sum of the array is: 15"
Result:
Report an issue