<?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. Xpath同时选取不同属性的元素

    如:一个论坛中,有置顶贴和普通贴,它们使用了不同的class,但这两类帖子都是需要的内容,需要同时爬下来 假设置顶贴class="top",普通贴class="commo ...

  2. JPA报错, PersistenceException_Unable to build Hibernate SessionFactory

    javax.persistence.PersistenceException: [PersistenceUnit: TestJPA] Unable to build Hibernate Session ...

  3. javaWeb后端学习记录

    java后端学习重点: 1.java语言特性: 基础知识,集合,多线程,并发,JVM,NIO,网络编程,设计模式.  (★★★★★) jdk源码中有大量的数据结构与java语言细节.jdk源码着重看c ...

  4. hdoj1251-统计难题 【字典树】

    http://acm.hdu.edu.cn/showproblem.php?pid=1251 统计难题 Time Limit: 4000/2000 MS (Java/Others)    Memory ...

  5. 平衡二叉树Balanced Binary Tree

    [抄题]: Given a binary tree, determine if it is height-balanced. For this problem, a height-balanced b ...

  6. 解读超轻量级DI容器-Guice与Spring框架的区别【转载】

    依赖注入,DI(Dependency Injection),它的作用自然不必多说,提及DI容器,例如spring,picoContainer,EJB容器等等,近日,google诞生了更轻巧的DI容器… ...

  7. ADF 入门帮助

    本文是由英文帮助翻译所得: 1>task flows “任务流 task flows”可以包括非可视化的组件,比如方法调用.“页片段 page fragment”可以运行在一个页面的某个局部区域 ...

  8. 使用springmvc从页面中获取数据,然后根据获得的参数信息进行修改,如果修改的数据中含有不是基本数据类型的参数。比如传的参数中有Date类型的数据时,需要我们进行参数类型转换。

    1.1 需求 在商品修改页面可以修改商品的生产日期,并且根据业务需求自定义日期格式. 1.2 需求分析 由于日期数据有很多格式,所以springmvc没办法把字符串转换成日期类型.所以需要自定义参数绑 ...

  9. 【D3D】Direct3D中LPRECT(上左右底)和LPoint(x,y)之前转换

    D3DSprite.cpp void CD3DSprite::DrawText(CD3DFont *pFont, char *szString, RECT &DesRect, D3DCOLOR ...

  10. Spark cache、checkpoint机制笔记

    Spark学习笔记总结 03. Spark cache和checkpoint机制 1. RDD cache缓存 当持久化某个RDD后,每一个节点都将把计算的分片结果保存在内存中,并在对此RDD或衍生出 ...