PHP array_sum() Function

PHP array_sum() Function

The array_sum() function in PHP is used to calculate the sum of values in an array.

Syntax

Parameter

array(required)– This array represents the input array.

Return

This function returns the sum of values as an integer or float value, or it returns 0 if the specified array is empty.

Example 1

Output

Example 2

Output

Example 3

Output

Example 4

Output