In this, Tutorial we are Learning array_sum() function in PHP. This Function is used to Calculate the sum of values in an array. This function returns the sum of values in an array. This Function is available in php 4 and above Php Version. How to calculate the sum of values in an array using array_sum() function.

It Calculates the sum of values in an array and returns the sum of values in an array as a integer or float data type. How to calculate the sum of values in an array in PHP.

### Syntax & Example

1 2 3 4 5 6 |
<?php $array1 = array(10, 15, 25, 50); echo array_sum($array1); //Output: 100 ?> |

In this Example Function return integer values. This Function is return a integer and float values.

1 2 3 4 5 6 |
<?php $array2 = array("a" => 2, "b" => 2.5, "c" => 4.6, "d" => 9.4); echo array_sum($array2); // Output: 18.5 ?> |

In this Example Function The sum of array is a float valuesfunction return Float values.