PHP Array Sum Example | PHP array_sum() Function Tutorial is today’s topic. It returns the sum of all the values in the array. It takes an array parameter and returns the sum of all the values in it. It returns the 0 if the array is empty. The returned sum may be integer or float.

PHP Array Sum Example

It calculates a sum of values in an array.

See the following syntax.

array_sum($array)

Now, see the following code example.

<?php

// app.php

$arr = [19, 21, 46];
echo array_sum($arr);

#php #php array sum

PHP Array Sum Example | PHP array_sum() Function Tutorial
4.25 GEEK