Home >Backend Development >PHP Tutorial >按字母排序,该怎么处理

按字母排序,该怎么处理

WBOY
WBOYOriginal
2016-06-13 11:55:31996browse

按字母排序
array( 1=>'ab', 2=>'cc', 3=> 'de' )

保持键值,按字母排序。。怎么弄的?
------解决方案--------------------
现在就是按照字母排序的
倒序来排?
------解决方案--------------------
手册搜索“ asort”   "uasort"
------解决方案--------------------
倒序排:

<br /><?php<br />$arr = array( 1=>'ab', 2=>'cc', 3=> 'de');<br />print_r($arr);<br />uasort($arr,'cmp');<br />print_r($arr);<br /><br />function cmp($a, $b){<br />	if($a==$b){<br />		return 0;<br />	}<br />	return ($a<$b)? 1 : -1;<br />}<br />?><br />

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn