function mean ($a)
{
//variable and initializations
$the_result = 0.0;
$the_array_sum = array_sum($a); //sum the elements
$number_of_elements = count($a); //count the number of elements
//calculate the mean
$the_result = $the_array_sum / $number_of_elements;
//return the value
return $the_result;
} |