What is the best way to get the median value from an array of integers?

I have a very long form, which is essentially the same mini-form (group 
of fields) repeated a number of times with different names (simple 
though, I use a 'for' loop to give each field a number that corresponds 
to which mini-form it belongs to).

This was an efficient way for me to let the user specify how many 
mini-forms they need to fill out for their purposes, because it might 
not always be the same.  HOWEVER... at the end of the day, when they are 
done filling out this long form full of groups of inputs, it needs to be 
added to a database.  That's the easy part.  The hard part is that I 
need to echo a value back to the user -- and this value corresponds to 
the median of all the values in field X.  Wait, this is too hard to 
explain.  Let me simplify:

The web page features ten listboxes, each of which contains the same 
options.  Let's say that you can choose A, B, C, D, or E from each 
listbox.  Submit the form, run some code to figure out which was 
most-frequently selected, and then display that value on the next page.

That's all I really want to do, but I'm pretty bad at math -- I could 
enter all the values into an array and run some kind of averaging code 
on them, but the problem is that I don't want an "average", I need the 
"most-chosen" value.

Thanks if you have any advice.



Erik Price
Web Developer Temp
Media Lab, H.H. Brown

PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to