php数组排序的函数有几个

本文操作系统:windows7系统、PHP5.6版本、DELL G3电脑。

1.排序函数

sort() – 对数组进行升序排列

rsort() – 对数组进行降序排列

asort() – 根据关联数组的值,对数组进行升序排列

ksort() – 根据关联数组的键,对数组进行升序排列

arsort() – 根据关联数组的值,对数组进行降序排列

krsort() – 根据关联数组的键,对数组进行降序排列

2.sort 函数

<?php

$sec="ailx10,ailx12,ailx13,ailx11";
$hack=explode(",",$sec);
sort($hack);
$sec2=implode(",",$hack);
print"排序前:".$sec."\n";
print"排序后:".$sec2;

3.asort 函数

<?php

$hack_biji=array("黑客"=>"hacker",
"网络安全"=>"net_sec",
"人工智能"=>"AI");

asort($hack_biji);

print"排序后:";
foreach($hack_bijias$key=>$value){
print"$key==>$value\n";
}
原文来自:https://www.py.cn
© 版权声明
THE END
喜欢就支持一下吧
点赞8 分享
评论 抢沙发
头像
欢迎您留下宝贵的见解!
提交
头像

昵称

取消
昵称表情代码图片

    暂无评论内容