I have the following array:
array(
a => 6.75,
b => 5.45,
c => 8.76,
d => 7.76,
e => 8.16,
f => 2.76,
g => 4.67,
h => 9.01,
i => 5.42,
)
What I am looking to achieve is to average the top quartile.
In essence I need to order the array in descending order, then calculate what the top quartile will be (i.e. 9 (the numbers of elements in the array) x 25% = 2.25 rounded down to 2, so it would be the first two numbers that need to be averaged).
It's this figure I'm looking for.
I'm struggling to figure out how to achieve this and whether it's best to do this within PHP or via a query to the MySQL database.
Any and all advice, feedback and suggestions welcomed.