Created
November 4, 2014 16:16
-
-
Save rjmunro/9e1b441ac46d1608dae0 to your computer and use it in GitHub Desktop.
PHP array_average function
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
/** | |
* Average an array | |
* | |
* I can't belive this isn't built in to PHP. | |
* | |
* @param float[] $array | |
* @return float | |
*/ | |
function array_average($array) { | |
return array_sum($array) / count($array); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment