1
I was looking to create a ranking system. For this I thought to put all the values within one Array
and then through a function arrange it from the largest to the smallest. However, each time I make each position, I always have to make a larger code (and I don’t know how many records they will have). The code would be similar to 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 as I will never know how many records I will keep doing this for several other records.
Is there any way to do it more dynamically?
For those who still don’t understand, I want an array
x=(1,4,3,2,5,6,9,8,7,0)
become an arrayy=(9,8,7,6,5,4,3,2,1,0)
function
sort
– Isac