Created
July 7, 2015 12:43
-
-
Save srdjanmarjanovic/e73b3b9a0fa0c44dbbb8 to your computer and use it in GitHub Desktop.
Function to sum all members of an array with array_reduce
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function sum_array(array $params) { | |
| return array_reduce($params, function($sum, $item){ | |
| return $sum += $item; | |
| }, 0); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment