>
> 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.
>

As for the median value, there's a relatively easy way to do this in PHP:

1. Sort the array   (sort())
2. Count the number of elements in the array   (count())
3. Take the element that is equal to half the number of the elements
(rounded to an int, which way you round doesn't matter)
(really_easy_code())

Might be off-by-1 but that's fixed easily enough.

-- Daniel Grace



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

Reply via email to