CKTIS / PHP
arsort()
Ordina i punteggi in ordine decrescente nella stessa mappa.
Versione: PHP 8.4; repository runtime, production runtime not attested
Sintassi
arsort(array &$array, int $flags = SORT_REGULAR): trueOrdina i punteggi in ordine decrescente nella stessa mappa. SORT_NUMERIC confronta numeri e conserva le chiavi. In PHP 8 i pari merito mantengono l’ordine iniziale. Restituisce true.
Firma
arsort(array &$array, int $flags = SORT_REGULAR): true
Output dell’esempio
[true,["rain","snow","sun"]]
Esempi
<?php
$scores = ["sun"=>4, "rain"=>7, "snow"=>7];
$ok = arsort($scores, SORT_NUMERIC);
echo json_encode([$ok, array_keys($scores)]);
Risultato
[true,["rain","snow","sun"]]