number to sort in php code example
Example 1: sort array of array php
sort() //sort arrays in ascending order
rsort() //sort arrays in descending order
asort() //sort associative arrays in ascending order, according to the value
ksort() //sort associative arrays in ascending order, according to the key
arsort() //sort associative arrays in descending order, according to the value
krsort() //sort associative arrays in descending order, according to the key
//Example
$array = array(1, 3, 2);
sort($array) //1, 2, 3
Example 2: php sort()
<?php
$fruits = array("Zitrone", "Orange", "Banane", "Apfel");
sort($fruits);
foreach ($fruits as $key => $val) {
echo "fruits[" . $key . "] = " . $val . "\n";
}
?>