How to use array sum in PHP
In this article, I will explain how the array_sum() function can be used in PHP.
array_sum() function in PHP
Syntax
Parameter
Example
The following example show to how the array_sum() function can be used in PHP.
<html>
<body>
<h3 style="color: slategrey;">array_sum() function example in PHP</h3>
<?php
$a = array(1, 2, 3, 4);
echo "sum of array1(a) = " . array_sum($a) . "<br />";
$b = array("a" => 2.1, "b" => 3.3, "c" => 4.4);
echo "sum of array2(b) = " . array_sum($b) . "<br />";
?>
</body>
</html>
|
Output
You may also want to read these related articles here
Ask Your Question
Got a programming related question? You may want to post your question here