fluffos/docs/stdlib/numbers/array_sum.md

31 lines
597 B
Markdown
Raw Permalink Normal View History

---
title: stdlib / array_sum
---
2023-11-25 09:50:24 -08:00
# array_sum
### NAME
array_sum() - return the sum of all of the numeric elements of the passed array
### SYNOPSIS
int|float sum( mixed* );
### DESCRIPTION
This function will aggregate the values of all elements of the passed
array into a single return value. The array may be any combination of
int or float and the appropriate type will be returned based on the
final total.
### EXAMPLE
2020-12-10 16:42:33 -08:00
```c
array_sum( ({ 1, 2, 3, 4, 5, 6 }) ); // Result: 21
array_sum( ({ 1, 2, 3.5, 4, 5, 6 }) ); // Result: 21.500000
2020-12-10 16:42:33 -08:00
```
### SEE ALSO
sum