I need to know how I can find the three greatest numbers of an array. Currently I can only find the greatest number of an array, but I want to have the three greatest of it:
$avg = array();
$avg[20,10,30,50,80,90,220];
echo max($avg);
Maybe you can help me by this?
// The array
$avg = [20,10,30,50,80,90,220];
// remove duplicates if any
$avg = array_unique($avg);
// sort in descending order
rsort($avg);
// get the first three elements
$avg = array_slice($avg, 0, 3);