Skip to content

Instantly share code, notes, and snippets.

@rjmunro rjmunro/average.php
Created Nov 4, 2014

Embed
What would you like to do?
PHP array_average function
/**
* 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
You can’t perform that action at this time.