PHP Functions - arsort()

 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()

时间: 2024-08-07 04:42:08

PHP Functions - arsort()的相关文章

Adding New Functions to MySQL(User-Defined Function Interface UDF、Native Function)

catalog 1. How to Add New Functions to MySQL 2. Features of the User-Defined Function Interface 3. User-Defined Function 4. UDF Argument Processing 5. UDF Return Values and Error Handling 6. UDF Compiling and Installing 7. Adding a New Native Functio

POJ 1080 Human Gene Functions(LCS)

Description It is well known that a human gene can be considered as a sequence, consisting of four nucleotides, which are simply denoted by four letters, A, C, G, and T. Biologists have been interested in identifying human genes and determining their

学习Oracle分析函数(Analytic Functions)

Oracle提供了一些功能很强大的分析函数,使用这些函数可以完成可能需要存储过程来实现的需求. 分析函数计算基于一组数据行的聚合值,它们不同于聚合函数的是,它们为每一组返回多行结果.分析函数是除ORDER BY子句之外,在查询语句中最后执行的.所有的join和所有的WHERE ,GROUP BY 和HAVING子句都在分析函数之前执行.所以分析函数只能出现在select或ORDER BY子句中. 下图为11.2版本官方文档中给出的语法示意图: 下面简单介绍一下各个部分: analytic_fun

模板类的约束模板友元函数:template friend functions

本来这篇博客是不打算写的,内容不是很难,对于我自己来讲,更多的是为了突出细节. 所谓template friend functions,就是使友元函数本身成为模板.基本步骤:1,在类定义的前面声明每个模板函数.eg:template <typename T> void counts(); template <typename T> void report<>(T &);2,在类声明中再次将模板声明为友元. template <typename TT>

&lt;QtEndian&gt; - Endian Conversion Functions

The <QtEndian> header provides functions to convert between little and big endian representations of numbers. More... Functions T qFromBigEndian(const uchar * src)T qFromBigEndian(T src)T qFromLittleEndian(const uchar * src)T qFromLittleEndian(T src

python3.4 build in functions from 官方文档 翻译中

2. Built-in Functions https://docs.python.org/3.4/library/functions.html?highlight=file The Python interpreter has a number of functions and types built into it that are always available. They are listed here in alphabetical order.     Built-in Funct

The difference of Methods and Functions

Functions Functions are self-contained chunks of code that perform a specific task. You give a function a name that identifies what it does, and this name is used to “call” the function to perform its task when needed. Swift’s unified function syntax

NVIDIA CG语言 函数之所有数学类函数(Mathematical Functions)

数学类函数(Mathematical Functions) abs(x) 返回标量和向量x的绝对值 如果x是向量,则返回每一个成员的绝对值 acos(x) 返回标量和向量x的反余弦 x的范围是[-1,1],返回值的范围是[0,π], 如果x是向量,则返回每一个成员的反余弦 all(x) 如果一个布尔标量为真,或者布尔向量的所有成员为真,则返回真 any(x) 如果一个布尔标量为真,或者布尔向量成员存在真值,则返回真 asin(x) 返回标量和向量x的反正弦 x的范围是[-1,1],返回值的范围是

Functions

1 Local static variables Local static variables are not destroyed when the function ends; they are destroyed when the program terminates. 2. Function parameter list Parameter names are optional. However, there is no way to use an unnamed parameter. A