PHP array_sum() Function
Last Updated : 17 Mar 2025
The array_sum( ) function is an inbuilt function of PHP. The array_sum( ) function calculates the sum of values in an array and returns the sum of values in an array as an integer or float. This function was introduced in PHP 4.0.4.
Syntax
Parameters
| Parameter | Description | Is compulsory |
|---|---|---|
| array | It specifies an array. | compulsory |
Return
The array_sum( ) function returns the sum of values.
Example 1
Output:
130
Example 2
Output:
0
Example 3
Output:
39.7
Example 4
Output:
122.12
Next TopicPhp-array-uasort-function