- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
array_sum() function in PHP
The array_sum() function returns the sum of the values in an array. The returned value can be integer or float. It returns 0 if the array is empty.
Syntax
array_sum(arr)
Parameters
- arr − the specified array
Return
The array_sum() function returns the sum of values. The returned value can be integer or float. It returns 0 if the array is empty.
Example
The following is an example −
<?php $arr = array(50, 100, 150, 300); echo array_sum($arr); ?>
Output
The following is the output −
600
Example
Let us see another example −
<?php $arr = array("a"=>29.8,"b"=>66.4); echo array_sum($arr); ?>
Output
The following is the output −
96.2
Advertisements