array_multisort对多维数组排序
程序员文章站
2023-12-23 16:23:22
...
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); } }