array_sum
Calculates and returns the sum of all values in an array as an integer or float.
Parameters
main.php
Return Values
int|float
Returns the sum of values as integer or float
On success:Sum of all numeric values in the array
On failure:0 if the array is empty
Notes
- Non-numeric values are treated as 0 in the calculation
- String numbers are automatically converted to numeric values
- Returns 0 for empty arrays
- Useful for quick calculations without loops
Changelog
- Function has been available since PHP 4.0.6
Related Functions
round
MathRounds a float to the specified number of decimal places using specified rounding mode.
mathprecisioncalculate