码迷,mamicode.com
首页 > 编程语言 > 详细

多维数组排序

时间:2019-03-14 15:16:12      阅读:195      评论:0      收藏:0      [点我收藏+]

标签:als   []   iso   col   exist   UNC   数组排序   color   func   

/**
 *  多维数组排序
 *
 * @access    public
 * @param     array   $arrays      多维数组
 * @param     string  $sort_key    排序字段
 * @param     striny  $sort_order  排列顺序
 * @param     string  $sort_type   排序类型
 * @return    array
 */
if ( ! function_exists(‘array_sort‘)){
    function array_sort($arrays=[], $sort_key=‘‘,$sort_row=‘‘, $sort_order = SORT_ASC, $sort_type = SORT_NUMERIC ){
        if(is_array($arrays)){
            foreach ($arrays as $array){
                if(is_array($array)){
                    $key_arrays[] = $array[$sort_key];
                    $row_arrays[] = $array[$sort_row];
                }else{
                    return false;
                }
            }
        }else{
            return false;
        }
        array_multisort($key_arrays,$sort_order,$sort_type,$row_arrays,$sort_order,$sort_type,$arrays,$sort_order,$sort_type);
        return $arrays;
    }
}

 

多维数组排序

标签:als   []   iso   col   exist   UNC   数组排序   color   func   

原文地址:https://www.cnblogs.com/ningjiabing/p/10530206.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!