时间:2021-07-01 10:21:17 帮助过:6人阅读
- php
- functioncmp($a,$b){
- if($a[”nums”]==$b[”nums”]){
- return0;
- }
- return($a[”nums”]<$b[”nums”])?-1:1;
- }
- $arr=Array(
- 0=>Array(
- “username”=>owen,
- “nums”=>2,
- ),
- 1=>Array(
- “username”=>d5s,
- “nums”=>5,
- ),
- 2=>Array(
- “username”=>pt,
- “nums”=>3,
- ),
- );
- uasort($arr,“cmp”);
- echo‘<prestyleprestyle=”text-align:left”>’;
- print_r($arr);
- echo‘< SPAN>pre>’;
- ?>
- Array
- (
- [0]=>Array
- (
- [username]=>owen
- [nums]=>2
- )
- [2]=>Array
- (
- [username]=>pt
- [nums]=>3
- )
- [1]=>Array
- (
- [username]=>d5s
- [nums]=>5
- )
- )
http://www.bkjia.com/PHPjc/446522.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/446522.htmlTechArticle学习PHP时,你可能会遇到PHP多维数组排序问题,这里将介绍PHP多维数组排序问题的解决方法,在这里拿出来和大家分享一下,希望对大家有...