I don t want to say that I m a newb, because I don t think I am. However this question was rather difficult to answer. I ve only been coding PHP for around 8 months, and I imagine that there is a much better way of accomplishing such an effect. Based on my skill set I choose to use PHP and came up with this:
<?php
$variable = array();
$variable[1] = 15;
$variable[2] = 30;
$variable[3] = 9;
$variable[4] = 86;
$variable[5] = 46;
$variable[6] = 12;
$variable[7] = 86;
## Clean the array of duplicates
$variable = array_unique($variable);
## Sort array from greatest to lease in DESC order
rsort($variable);
for ($i = 0; $i < 3; $i++):
echo $variable[$i]."<br />";
endfor;
?>
The breakdown
- First declare your array
- Then your array items
- Clean the array with "array_unique" to remove reiterated values
- Use "rsort" to sort array from greatest to least
- Initiate a for loop in which $i equals 0, run only while $i is less then 3, add one to $i for each iteration
- Echo the array item
Good luck!