|
6.2.63 sort()Trie le tableau[ Exemples avec sort ] PHP 3, PHP 4
void
sort (
array
array
)
sort
trie le tableau
array
. Les
éléments seront triés du plus petit au plus grand.
| Exemple avec sort |
<?php $fruits = array("papaye","orange","banane","ananas"); sort($fruits); for(reset($fruits); $key = key($fruits); next($fruits)) { echo "fruits[$key] = ".$fruits[$key]."\n"; } ?>
|
Cet exemple va afficher :
fruits[0] = ananas
fruits[1] = banane
fruits[2] = orange
fruits[3] = papaye
Les fruits ont été classés dans l'ordre alphabétique.
Voir aussi
array-multisort
,
arsort
,
asort
,
krsort
,
ksort
,
natsort
,
natcasesort
,
rsort
,
uasort
,
uksort
et
usort
.
|