I was looking to create a ranking system. For this I thought of putting all the values inside a Array
and then through a function to organize it from the largest to the smallest. However, every time I do each position, I always have to make a larger code (and I do not know how many records will be). The code would look like this:
<?php
// essa função recebe um array como parâmetro
function ordenaArray($array){
$arrayOrdenado = array();
$indice = 0;
$maior = 0;
for($i = 0; $i <= count($array); $i++){
if($array[$i] >= $maior){
$maior = $array[$i];
}
}
$arrayOrdenado[$indice] = $maior;
$indice++;
}
?>
I can do this for all records, but since I'll never know how many records they'll have, I'll keep doing this for several other records.
Do you have any way to do this more dynamically?
For those who still do not understand, I want an array
x=(1,4,3,2,5,6,9,8,7,0)
to turn an arrayy=(9,8,7,6,5,4,3,2,1,0)