数组

 array(11) {
[0] => array(7) {
["food_id"] => string(2) "31"
["food_name"] => string(6) "啤酒"
["food_num"] => string(2) "22"
["foods_id"] => string(1) "1"
["foods_name"] => string(6) "凉菜"
["ROW_NUMBER"] => string(1) "1"
["x"] => int(2)
}
[1] => array(7) {
["food_id"] => string(2) "32"
["food_name"] => string(6) "红酒"
["food_num"] => string(2) "24"
["foods_id"] => string(1) "1"
["foods_name"] => string(6) "凉菜"
["ROW_NUMBER"] => string(1) "2"
["x"] => int(15)
}
[2] => array(7) {
["food_id"] => string(2) "33"
["food_name"] => string(6) "白酒"
["food_num"] => string(2) "12"
["foods_id"] => string(1) "1"
["foods_name"] => string(6) "凉菜"
["ROW_NUMBER"] => string(1) "3"
["x"] => int(0)
}
[3] => array(7) {
["food_id"] => string(2) "34"
["food_name"] => string(6) "拉菲"
["food_num"] => string(1) "0"
["foods_id"] => string(1) "1"
["foods_name"] => string(6) "凉菜"
["ROW_NUMBER"] => string(1) "4"
["x"] => int(0)
}
[4] => array(7) {
["food_id"] => string(2) "35"
["food_name"] => string(8) "88拉菲"
["food_num"] => string(2) "24"
["foods_id"] => string(1) "8"
["foods_name"] => string(6) "红酒"
["ROW_NUMBER"] => string(1) "5"
["x"] => int(12)
}
[5] => array(7) {
["food_id"] => string(2) "36"
["food_name"] => string(9) "葡萄酒"
["food_num"] => string(1) "0"
["foods_id"] => string(1) "8"
["foods_name"] => string(6) "红酒"
["ROW_NUMBER"] => string(1) "6"
["x"] => int(0)
}
[6] => array(7) {
["food_id"] => string(2) "37"
["food_name"] => string(9) "矿泉水"
["food_num"] => string(1) "0"
["foods_id"] => string(1) "1"
["foods_name"] => string(6) "凉菜"
["ROW_NUMBER"] => string(1) "7"
["x"] => int(0)
}
[7] => array(7) {
["food_id"] => string(2) "38"
["food_name"] => string(6) "可乐"
["food_num"] => string(1) "0"
["foods_id"] => string(1) "1"
["foods_name"] => string(6) "凉菜"
["ROW_NUMBER"] => string(1) "8"
["x"] => int(0)
}
[8] => array(7) {
["food_id"] => string(2) "39"
["food_name"] => string(6) "雪碧"
["food_num"] => string(2) "50"
["foods_id"] => string(1) "1"
["foods_name"] => string(6) "凉菜"
["ROW_NUMBER"] => string(1) "9"
["x"] => int(50)
}
[9] => array(7) {
["food_id"] => string(2) "40"
["food_name"] => string(9) "百岁山"
["food_num"] => string(1) "0"
["foods_id"] => string(1) "1"
["foods_name"] => string(6) "凉菜"
["ROW_NUMBER"] => string(2) "10"
["x"] => int(0)
}
[10] => array(7) {
["food_id"] => string(2) "41"
["food_name"] => string(6) "冰霜"
["food_num"] => string(1) "0"
["foods_id"] => string(1) "1"
["foods_name"] => string(6) "凉菜"
["ROW_NUMBER"] => string(2) "11"
["x"] => int(0)
}
}

  方法:

 foreach ($food as $key => $row) {
$id[$key] = $row['x'];
}
array_multisort($id, SORT_DESC , $food);

  结果:

 array(11) {
[0] => array(7) {
["food_id"] => string(2) "39"
["food_name"] => string(6) "雪碧"
["food_num"] => string(2) "50"
["foods_id"] => string(1) "1"
["foods_name"] => string(6) "凉菜"
["ROW_NUMBER"] => string(1) "9"
["x"] => int(50)
}
[1] => array(7) {
["food_id"] => string(2) "32"
["food_name"] => string(6) "红酒"
["food_num"] => string(2) "24"
["foods_id"] => string(1) "1"
["foods_name"] => string(6) "凉菜"
["ROW_NUMBER"] => string(1) "2"
["x"] => int(15)
}
[2] => array(7) {
["food_id"] => string(2) "35"
["food_name"] => string(8) "88拉菲"
["food_num"] => string(2) "24"
["foods_id"] => string(1) "8"
["foods_name"] => string(6) "红酒"
["ROW_NUMBER"] => string(1) "5"
["x"] => int(12)
}
[3] => array(7) {
["food_id"] => string(2) "31"
["food_name"] => string(6) "啤酒"
["food_num"] => string(2) "22"
["foods_id"] => string(1) "1"
["foods_name"] => string(6) "凉菜"
["ROW_NUMBER"] => string(1) "1"
["x"] => int(2)
}
[4] => array(7) {
["food_id"] => string(2) "33"
["food_name"] => string(6) "白酒"
["food_num"] => string(2) "12"
["foods_id"] => string(1) "1"
["foods_name"] => string(6) "凉菜"
["ROW_NUMBER"] => string(1) "3"
["x"] => int(0)
}
[5] => array(7) {
["food_id"] => string(2) "34"
["food_name"] => string(6) "拉菲"
["food_num"] => string(1) "0"
["foods_id"] => string(1) "1"
["foods_name"] => string(6) "凉菜"
["ROW_NUMBER"] => string(1) "4"
["x"] => int(0)
}
[6] => array(7) {
["food_id"] => string(2) "36"
["food_name"] => string(9) "葡萄酒"
["food_num"] => string(1) "0"
["foods_id"] => string(1) "8"
["foods_name"] => string(6) "红酒"
["ROW_NUMBER"] => string(1) "6"
["x"] => int(0)
}
[7] => array(7) {
["food_id"] => string(2) "37"
["food_name"] => string(9) "矿泉水"
["food_num"] => string(1) "0"
["foods_id"] => string(1) "1"
["foods_name"] => string(6) "凉菜"
["ROW_NUMBER"] => string(1) "7"
["x"] => int(0)
}
[8] => array(7) {
["food_id"] => string(2) "38"
["food_name"] => string(6) "可乐"
["food_num"] => string(1) "0"
["foods_id"] => string(1) "1"
["foods_name"] => string(6) "凉菜"
["ROW_NUMBER"] => string(1) "8"
["x"] => int(0)
}
[9] => array(7) {
["food_id"] => string(2) "40"
["food_name"] => string(9) "百岁山"
["food_num"] => string(1) "0"
["foods_id"] => string(1) "1"
["foods_name"] => string(6) "凉菜"
["ROW_NUMBER"] => string(2) "10"
["x"] => int(0)
}
[10] => array(7) {
["food_id"] => string(2) "41"
["food_name"] => string(6) "冰霜"
["food_num"] => string(1) "0"
["foods_id"] => string(1) "1"
["foods_name"] => string(6) "凉菜"
["ROW_NUMBER"] => string(2) "11"
["x"] => int(0)
}
}

php多维数组排序的更多相关文章

  1. JS二维数组排序组合

    需求是这样的:http://q.cnblogs.com/q/29093/ 这里简述一下: 现在有一个不确定长度的数组.比如:var temp=[["Fu","Hai&qu ...

  2. PHP二维数组排序(list_order)

    /** * 对二维数组进行排序 * 模拟 数据表记录按字段排序 * * <code> * @list_order($list, $get['orderKey'], $get['orderT ...

  3. php 二维数组排序,多维数组排序

    对2维数组或者多维数组排序是常见的问题,在php中我们有个专门的多维数组排序函数,下面简单介绍下: array_multisort(array1,sorting order, sorting type ...

  4. PHP array_multisort() 函数详解 及 二维数组排序(模拟数据表记录按字段排序)

    一.先看最简单的情况. 有两个数组: $arr1 = array(1, 9, 5); $arr2 = array(6, 2, 4); array_multisort($arr1, $arr2); pr ...

  5. php基础篇-二维数组排序 array_multisort

    原文:php基础篇-二维数组排序 array_multisort 对2维数组或者多维数组排序是常见的问题,在php中我们有个专门的多维数组排序函数,下面简单介绍下: array_multisort(a ...

  6. php 对多维数组排序array_multisort

    php 对多维数组排序array_multisort 排序顺序标志: SORT_ASC - 按照上升顺序排序 SORT_DESC - 按照下降顺序排序 排序类型标志: SORT_REGULAR - 将 ...

  7. 使用 array_multisort 对多维数组排序

    array_multisort() 函数对多个数组或多维数组进行排序. 用法详看:http://www.w3school.com.cn/php/func_array_multisort.asp 例子: ...

  8. 使用php对多维维数组排序。

    要多php的多维数组排序,可以使用php里的内置函数:array_multisort(); 语法:array_multisort(array1,sorting order,sorting type,a ...

  9. PHP二维数组排序(感谢滔哥)

    滔哥原创 /* _ooOoo_ o8888888o 88" . "88 (| -_- |) O\ = /O ____/`---'\____ .' \\| |// `. / \\|| ...

  10. PHP 二维数组排序保持键名不变

    对二维数组指定的键名排序,首先大家想到的是array_multisort函数,关于array_multisort的用法我之前也写了一篇废话不多言,我们看个实例: <?php $data = ar ...

随机推荐

  1. 3D打印GCODE文件学习(一)

    我家有一个天威的入门级的3D打印机.它有一个配套的软件叫“Rrint-RiteCoLiDo Repetier-Host V1.5.5”,用来连接.控制打印机.同时它可以加载各种切片软件,对各种3D模型 ...

  2. 阶段01Java基础day24多线程+GUI

    25.01_多线程(多线程方法) 1.yield让出cpu 2.setPriority()设置线程的优先级 25.02_多线程(单例设计模式)(掌握) 单例设计模式:保证类在内存中只有一个对象. 如何 ...

  3. [python] 使用Jieba工具中文分词及文本聚类概念

    声明:由于担心CSDN博客丢失,在博客园简单对其进行备份,以后两个地方都会写文章的~感谢CSDN和博客园提供的平台.        前面讲述了很多关于Python爬取本体Ontology.消息盒Inf ...

  4. 一篇提及如何通过串口读取并提取GPS信号的论文

    一篇提及如何通过串口读取并提取GPS信号的论文 作者:崔杰 梁计春 王国军 目前,在用计算机进行数据传输时,常用的是串行通信方式.在Visual C++的编程中,既可以用Windows API函数进行 ...

  5. VS2013/VS2015/VS2017通过oschina托管代码

    1.到http://git.oschina.net注册账号,创建项目,这一步不做详细描述,创建后效果如图 2.打开VS创建项目,为了测试,创建一个空白解决方案 3.把解决方案添加到源代码管理(这一步仅 ...

  6. 使用element-ui 遇到的问题

    Pagination 分页 在使用分页的时候,每次切换pageSize的时候,需要把current-page置为1 重新加载数据. 但是当current-page !== 1的时候,修改current ...

  7. FreeSWITCH部署与功能配置

    一.FreeSWITCH服务部署 1.wget http://www.freeswitch.org.cn/Makefile && make install 2.cd freeswitc ...

  8. 如何在Linux下添加函数库

    如何为Linux增加库一. 静态库在Linux下的静态库是以.a为后缀的文件.1. 建静态库h1.c 源文件#include<stdio.h>void hello1(){printf(“t ...

  9. Spring Boot配置文件详解

    挖个坑先 http://www.cnblogs.com/itdragon/p/8686554.html http://www.cnblogs.com/jtlgb/p/8532280.html

  10. cocos2dx开发之util类&方法——取当前系统时间

    返回time_t,即从1970年1月1日至今的秒数 time_t getSysTime(){ time_t currentTime = time(NULL); return currentTime; ...