Re: Average Number For Math Functions

From: Date: Fri, 30 Aug 2002 01:51:45 +0000
Subject: Re: Average Number For Math Functions
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-114580@lists.php.net to get a copy of this message
At 05:55 PM 8/29/02 , JohnP wrote:
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
Nope - you'll have to 'roll your own' by looping though the set, or (if you have version >= 4.0.5) you can use array_reduce() in conjunction with the count() function. If these values are coming from a database, most databases have aggregate functions to do sums, averages, etc. -steve +------------------------------------------------------------------------+
| Steve Edberg                                      sbedberg@ucdavis.edu |
| Database/Programming/SysAdmin                            (530)754-9127 |
| University of California, Davis             http://pgfsun.ucdavis.edu/ |
+---------------------- Gort, Klaatu barada nikto! ----------------------+

« previous php.general (#114580) next »