- sort: documentation ( source)
<?php
$array = Array ( "0" => 12 , "1" => 17 , "2" => 5, "3" => 27, "4" => 5 );
//$array = sort($array);
$ranked = sort($array);
for($i = 0; $i < length($ranked); $i++){
for($j = 0; $j < length($array); $j++){
if($array[$i] == $sorted[$j]){
echo $array[$i] . ' has rank ' . $j;
}
}
}