if i remember 4th grade math class correctly...
<?
$total = 0;
$count = 0;
// get each of the numbers
foreach($array_of_the_numbers as $key => $value)
{
$total += $array_of_the_numbers[$key];
++$count;
}
// wow, that's a toughie!
$average = $total / $count;
// then you could make it pretty
$pretty_average = number_format($average, 1);
?>
booyah. :)
dave
-----Original Message-----
From: JohnP [mailto:[EMAIL PROTECTED]]
Sent: Thursday, August 29, 2002 5:56 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Average Number For Math Functions
Ok I looked at all the math functions for PHP but saw no way of returning
the average of a set of numbers - I plan on using this for a rating system -
any help?
--
John
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php