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

按字母排序,该怎么处理

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-13 11:55:31
Original
1008 people have browsed it

按字母排序
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 />
Copy after login

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template