今日总结:php数组排序函数

PHP - 数组排序函数

 

  • sort() - 对数组进行升序排列
  • rsort() - 对数组进行降序排列
  • asort() - 根据关联数组的值,对数组进行升序排列
  • ksort() - 根据关联数组的键,对数组进行升序排列
  • arsort() - 根据关联数组的值,对数组进行降序排列
  • krsort() - 根据关联数组的键,对数组进行降序排列

例:

<?php

$cars=array("Volvo","BMW","Toyota");

rsort($cars);
?>

posted @ 2022-04-03 23:20  stdrush  阅读(29)  评论(0)    收藏  举报