On Friday, March 1, 2002, at 02:28 PM, Jason Wong wrote:
> On Saturday 02 March 2002 02:03, Daniel Grace wrote: >> As for the median value, there's a relatively easy way to do this in >> PHP: > > I think Erik has gotten his terms mixed. He wants the "most-chosen" > value, > which is the "mode" and not "median". > > To get the mode, use array_count_values(); I told you guys I was bad at math! I don't even remember the terms... thanks to everyone who replied to this thread with advice, it looks like I can do: - grab all values from the desired inputs and slap them into an array - run the array against array_count_values() to get the number of each input value in that array (in the form of a new array) - rsort the resulting new array (of 'value => occurrences' form) to put the highest-numbered array at the beginning of the array - the key of the first element in this rsorted array is the value I am looking for -- the most-chosen value from the initial user inputs - array_flip the array inside the first element of the rsorted array to make the key into the value and vice versa - my desired value is now the value of the first element in the array It seems like a lot of work, but sounds logical. The end result is the most-chosen value from the user inputs becomes the value of the first element in the array returned by array_count_values() after that array has been rsorted and flipped. Crazy! Erik PS: can anyone see a flaw in this scheme? Can anyone even tell what I'm talking about? ---- Erik Price Web Developer Temp Media Lab, H.H. Brown [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php