<?php

 $characters = array('a','b','c','d','e','f');
arsort($characters);
print_r($characters);
/*
Array ( [5] => f [4] => e [3] => d [2] => c [1] => b [0] => a )
*/ $numbers = array(1,2,3,4,5,6,7,8);
arsort($numbers);
print_r($numbers);
/*
Array ( [7] => 8 [6] => 7 [5] => 6 [4] => 5 [3] => 4 [2] => 3 [1] => 2 [0] => 1 )
*/ $fruits = array('lemon' , 'orange' ,'banana' , 'apple');
arsort($fruits);
print_r($fruits);
/*
Array ( [1] => orange [0] => lemon [2] => banana [3] => apple )
*/ /*arsort()函数对中文的排序结果*/
$chinese = array('爱','本','吃','地');//ai-ben-chi-di
var_dump(arsort($chinese));
print_r($chinese);
/*
bool(true)
Array ( [0] => 爱 [1] => 本 [3] => 地 [2] => 吃 )
*/ $pingyin = array('ai','ben','chi','di');
arsort($pingyin);
print_r($pingyin);
/*
Array ( [3] => di [2] => chi [1] => ben [0] => ai )
*/
?>

结论:[单元索引关系不变,逆序排序]

  1.对英文字符排序是按照27个英文字母排列顺序进行逆序排列,单元索引关系保持不变;

  2.对数字排序是按照数字顺序进行逆序排列,单元索引关系保持不变;

问题:arsort()函数究竟是怎么对中文文字进行排序的

PHP Functions - arsort()的更多相关文章

  1. asp.net MVC helper 和自定义函数@functions小结

    asp.net Razor 视图具有.cshtml后缀,可以轻松的实现c#代码和html标签的切换,大大提升了我们的开发效率.但是Razor语法还是有一些棉花糖值得我们了解一下,可以更加强劲的提升我们 ...

  2. 【跟着子迟品 underscore】Array Functions 相关源码拾遗 & 小结

    Why underscore 最近开始看 underscore.js 源码,并将 underscore.js 源码解读 放在了我的 2016 计划中. 阅读一些著名框架类库的源码,就好像和一个个大师对 ...

  3. 【跟着子迟品 underscore】Object Functions 相关源码拾遗 & 小结

    Why underscore 最近开始看 underscore.js 源码,并将 underscore.js 源码解读 放在了我的 2016 计划中. 阅读一些著名框架类库的源码,就好像和一个个大师对 ...

  4. ajax的使用:(ajaxReturn[ajax的返回方法]),(eval返回字符串);分页;第三方类(page.class.php)如何载入;自动加载函数库(functions);session如何防止跳过登录访问(构造函数说明)

    一.ajax例子:ajaxReturn("ok","eval")->thinkphp中ajax的返回值的方法,返回参数为ok,返回类型为eval(字符串) ...

  5. QM模块包含主数据(Master data)和功能(functions)

    QM模块包含主数据(Master data)和功能(functions)   QM主数据   QM主数据 1 Material   Master MM01/MM02/MM50待测 物料主数据 2 Sa ...

  6. jQuery String Functions

    In today's post, I have put together all jQuery String Functions. Well, I should say that these are ...

  7. 2-4. Using auto with Functions

    在C++14中允许使用type deduction用于函数参数和函数返回值 Return Type Deduction in C++11 #include <iostream> using ...

  8. [Python] Pitfalls: About Default Parameter Values in Functions

    Today an interesting bug (pitfall) is found when I was trying debug someone's code. There is a funct ...

  9. Kernel Functions for Machine Learning Applications

    In recent years, Kernel methods have received major attention, particularly due to the increased pop ...

随机推荐

  1. python集合的交,差,并,补集合运算汇总

    集合操作实际用的不多,了解即可. 交集:          ( & 或者 intersection ) 并集:    ( | 或者 union ) 差集:   ( -  或者  differe ...

  2. Java8 lambda表达式语法 1

    本文主要记录自己学习Java8的历程,方便大家一起探讨和自己的备忘.因为本人也是刚刚开始学习Java8,所以文中肯定有错误和理解偏差的地方,希望大家帮忙指出,我会持续修改和优化.本文是该系列的第一篇, ...

  3. SearchEngine Note

    [SearchEngine Note] 1.查全率. 2.查准率. 3.查全率与查准率的关系. 4.四大系统. 5.权威性网页反向链接多.网页的平均出席为25.7,即平均每一个网页含有25.7个指向其 ...

  4. pymongo的常用操作

    环境:pymongo3.0.3,python3 以下是我整理的一些关于pymongo的操作,网上很多是用pymongo.Connecion()去连接数据库的,但是我这里连接一直提示没有这个包,如果大家 ...

  5. spine

    spine 英 [spʌɪn] 美 [spaɪn]  n.脊柱;[动,植] 棘,刺(如刺猬和海胆的刺);鱼鳍的刺;植物上的刺

  6. 浅谈python中的“ ==” 与“ is”

    在python中,== 与 is 之间既有区别,又有联系,本文将通过实际代码的演示,力争能够帮助读到这篇文章的朋友以最短的时间理清二者的关系,并深刻理解它们在内存中的实现机制.扯淡的话不多说,下面马上 ...

  7. iOS - OC - 网络请求 - 中文转码

    #import "ViewController.h" @interface ViewController () @end @implementation ViewControlle ...

  8. 让php支持多线程,win下安装pthreads

    1.检查PHP版本是否支持线程安全 在phpinfo()的显示页中,搜索Thread Safety,如果是enabled,则PHP版本是线程安全的. 2.在http://windows.php.net ...

  9. phpcms如何给已有的模块添加新功能?

    phpcms如何给已有的模块添加新功能? 方法一:直接在模块里的控制器文件中添加功能. 不建议使用此方法,因为一旦phpcms升级,有可能会覆盖模块中的文件, 导致你添加的功能丢失. 方法二:新建一个 ...

  10. MD5加密获得文件的MD5码

    哈希函数将任意长度的二进制字符串映射为固定长度的小型二进制字符串.加密哈希函数有这样一个属性:在计算不大可能找到散列为相同的值的两个不同的输入:也就是说,两组数据的哈希值仅在对应的数据也匹配时才会匹配 ...