I want to get the highest value, the second highest value and the third highest value
For example, I have an array like:
$n = array(100,90,150,200,199,
This should do the trick:
function maxNitems($array, $n = 3){ asort($array); return array_slice(array_reverse($array, true),0,$n, true); }
Use like:
maxNitems(array(100,90,150,200,199,155,15,186));