Home > php教程 > PHP源码 > array_multisort对多维数组排序

array_multisort对多维数组排序

PHP中文网
Release: 2016-05-25 17:03:27
Original
1287 people have browsed it

php代码

function sort_array($array, $keyid, $order='asc', $type='number') {
    if(is_array($array)) {
        foreach($array as $val) {
            $order_arr[] = $val[$keyid];
        }
 
        $order = ($order == 'asc') ? SORT_ASC: SORT_DESC;
        $type  = ($type == 'number') ? SORT_NUMERIC: SORT_STRING;
 
        array_multisort($order_arr, $order, $type, $array);
    }
}
Copy after login

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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template