public static function average($values)
    {
        $sum = array_sum($values);
        $count = count($values);

        // Avoid useless calculations
        if ($count == 0) {
            return 0;
        }

        return $sum / $count;
    }
public static function average($values)
    {
        $sum = array_sum($values);
        $count = count($values);

        // Avoid useless calculations
        if ($count == 0) {
            return 0;
        }

        return $sum / $count;
    }
public static function average ( $ values ) { $ sum = array_sum ( $ values ) ; $ count = count ( $ values ) ; // Avoid useless calculations if ( $ count == 0 ) { return 0 ; } return $ sum / $ count ; }
Finds the average

@param array $values
@return float
Finds the average