Manuel PHP

Précédent

 

Suivant

sort

sort -- Trie le tableau

Description

void sort(array array);

Cette fonction trie le tableau array. Les éléments seront triés du plus petit au plus grand.

Exemple 1. exemple sort()

$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é dans líordre alphabétique.

Voir aussi arsort(), asort(), ksort(), rsort(),et usort().

Précédent

Sommaire

Suivant

sizeof

Chapitre

uasort