Javatpoint Logo
Javatpoint Logo

PHP array_sum() function

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





Help Others, Please Share

facebook twitter pinterest