1、数组排序函数
- sort()-对数组升序排列
<pre>
<?php
$cars=array("Volvo","BMW","Toyota");
sort($cars); //数组排序
print_r($cars);//输出数组
?>
</pre>
- rsort()-对数组降序排序
<pre>
<?php
$cars=array("Volvo","BMW","Toyota");
rsort($cars); //数组排序
print_r($cars);//输出数组
?>
</pre>
- asort()-根据数组的值升序排序
<pre>
<?php
$age=array("Peter"=>"35","Ben"=>"37","Joe"=>"43");
asort($age);
print_r($age);
?>
</pre>
- ksort()-根据数组的键,对数组升序排序
<pre>
<?php
$age=array("Peter"=>"35","Ben"=>"37","Joe"=>"43");
ksort($age);
print_r($age);
?>
</pre>
- arsort()-根据数组的值降序排序
<pre>
<?php
$age=array("Peter"=>"35","Ben"=>"37","Joe"=>"43");
arsort($age);
print_r($age);
?>
</pre>
- krsort()-根据数组的键降序排序
<pre>
<?php
$age=array("Peter"=>"35","Ben"=>"37","Joe"=>"43");
krsort($age);
print_r($age);
?>
</pre>
![](https://i-blog.csdnimg.cn/blog_migrate/496dfd890119827a34b5fd83a58222ce.png)