Home > Backend Development > PHP Tutorial > 分享一种二维数组排序的简单方法,该如何处理

分享一种二维数组排序的简单方法,该如何处理

WBOY
Release: 2016-06-13 10:26:40
Original
731 people have browsed it

分享一种二维数组排序的简单方法

PHP code
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->function array_sort($arr,$field,$by=SORT_ASC)    {                   foreach($arr as $v) {              $r[] = $v[$field];            }         array_multisort($r,$by,$arr);         return $arr;    }    $array = array(                     array(´name´=>´手机´,´brand´=>´诺基亚´,´price´=>3000),                      array(´name´=>´笔记本电脑´,´brand´=>´lenovo´,´price´=>4000),                    );    $a=array_sort($array,´price´,SORT_DESC);    echo "<pre class="brush:php;toolbar:false">";    print_r($a);  
Copy after login


欢迎使用。。。



------解决方案--------------------
一直都是这个啊,呵呵。
------解决方案--------------------
还不如不封装呢 直接 array_multisort
------解决方案--------------------
php里有自动排序的函数的
------解决方案--------------------
三维数组是否要再封装一个?
------解决方案--------------------
探讨

三维数组是否要再封装一个?
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template