【php开源代码栏目提醒】:网学会员为广大网友收集整理了,all_sort.php,希望对大家有所帮助!
<?php
//sort排序
echo "sort排序<br>";
$fruits = array("lemon", "orange", "banana", "apple");
sort($fruits);
foreach ($fruits as $key => $val) {
echo "fruits[".$key."] = " . $val . "<br>";
}
//asort排序
echo "asort排序<br>";
$fruits = array("d" => "lemon", "a" => "orange", "b" => "banana", "c" => "apple");
arsort($fruits);
foreach ($fruits as $key => $val) {
echo "$key = $val <br>";
}
//ksort排序
echo "ksort排序<br>";
$fruits = array("d"=>"lemon", "a"=>"orange", "b"=>"banana", "c"=>"apple");
krsort($fruits);
foreach ($fruits as $key => $val) {
echo "$key = $val <br>";
}
//rsoft排序
echo "rsort排序<br>";
$fruits = array("lemon", "orange", "banana", "apple");
rsort($fruits);
foreach ($fruits as $key => $val) {
echo "$key = $val <br>";
}
//arsoft排序
echo "arsort排序<br>";
$fruits = array("d" => "lemon", "a" => "orange", "b" => "banana", "c" => "apple");
arsort($fruits);
foreach ($fruits as $key => $val) {
echo "$key = $val <br>";
}
//krsoft排序
echo "krsort排序<br>";
$fruits = array("d"=>"lemon", "a"=>"orange", "b"=>"banana", "c"=>"apple");
krsort($fruits);
foreach ($fruits as $key => $val) {
echo "$key = $val <br>";
}
?>