Created
August 7, 2019 18:31
-
-
Save parzibyte/030d253c492b09f1de849464a8d2a74e to your computer and use it in GitHub Desktop.
Ordenar arreglo numérico con PHP - https://parzibyte.me/blog/2018/10/15/ordenar-arreglo-php/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Ordenar un arreglo numérico en PHP | |
@author parzibyte.me/blog | |
Nota: si quieres cambiar el orden, simplemente invierte el arreglo después de ordenarlo: | |
https://parzibyte.me/blog/2018/10/15/invertir-arreglo-php/ | |
*/ | |
# El arreglo que tiene números desordenados | |
$numeros = [96, 28, 11, 55, 20, 2015, 500, 630, -10, -1, 200, 96]; | |
echo "El arreglo desordenado:\n"; | |
print_r($numeros); | |
#Lo ordenamos de modo numérico | |
sort($numeros, SORT_NUMERIC); | |
echo "El arreglo después de haber sido ordenado:\n"; | |
print_r($numeros); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment