sort

PHP -> Funkcie -> Array funkcie -> sort

Syntax

void sort(array arr);

Popis

Príkaz jazyka PHP
sort - Sort an array

This function sorts an array. Elements will be arranged from lowest to highest when this function has completed.

This example would display: fruits[0] = apple fruits[1] = banana fruits[2] = lemon fruits[3] = orange The fruits have been sorted in alphabetical order.

Príklad

$fruits = array("lemon","orange","banana","apple");
sort($fruits);
for(reset($fruits); $key = key($fruits); next($fruits)) {
  echo "fruits[$key] = ".$fruits[$key]."\n";
}


Pozri aj

arsort, asort, ksort, rsort, usort