Skip to content

Instantly share code, notes, and snippets.

@rjmunro
Created November 4, 2014 16:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rjmunro/9e1b441ac46d1608dae0 to your computer and use it in GitHub Desktop.
Save rjmunro/9e1b441ac46d1608dae0 to your computer and use it in GitHub Desktop.
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