标签:style blog color io 问题 cti ar div
1 <?php 2 3 4 $characters = array(‘a‘,‘b‘,‘c‘,‘d‘,‘e‘,‘f‘); 5 arsort($characters); 6 print_r($characters); 7 /* 8 Array ( [5] => f [4] => e [3] => d [2] => c [1] => b [0] => a ) 9 */ 10 11 12 13 $numbers = array(1,2,3,4,5,6,7,8); 14 arsort($numbers); 15 print_r($numbers); 16 /* 17 Array ( [7] => 8 [6] => 7 [5] => 6 [4] => 5 [3] => 4 [2] => 3 [1] => 2 [0] => 1 ) 18 */ 19 20 $fruits = array(‘lemon‘ , ‘orange‘ ,‘banana‘ , ‘apple‘); 21 arsort($fruits); 22 print_r($fruits); 23 /* 24 Array ( [1] => orange [0] => lemon [2] => banana [3] => apple ) 25 */ 26 27 /*arsort()函数对中文的排序结果*/ 28 $chinese = array(‘爱‘,‘本‘,‘吃‘,‘地‘);//ai-ben-chi-di 29 var_dump(arsort($chinese)); 30 print_r($chinese); 31 /* 32 bool(true) 33 Array ( [0] => 爱 [1] => 本 [3] => 地 [2] => 吃 ) 34 */ 35 36 $pingyin = array(‘ai‘,‘ben‘,‘chi‘,‘di‘); 37 arsort($pingyin); 38 print_r($pingyin); 39 /* 40 Array ( [3] => di [2] => chi [1] => ben [0] => ai ) 41 */ 42 ?>
结论:[单元索引关系不变,逆序排序]
1.对英文字符排序是按照27个英文字母排列顺序进行逆序排列,单元索引关系保持不变;
2.对数字排序是按照数字顺序进行逆序排列,单元索引关系保持不变;
问题:arsort()函数究竟是怎么对中文文字进行排序的
PHP Functions - arsort(),布布扣,bubuko.com
标签:style blog color io 问题 cti ar div
原文地址:http://www.cnblogs.com/shuman/p/3880396.html