This article introduces the two-dimensional array sorting in PHP. It has a certain reference value. Now I share it with you. Friends in need can refer to it
// $array Sorting array
// $sort_key Sorting conditions
// $sort_order Sorting method
#SORT_ASC - Default, sort in ascending order. (A-Z)
SORT_DESC - Sort in descending order. (Z-A)
// $sort_type Sort data type
my_sort($array, 'sort_time', SORT_DESC, SORT_STRING); // 方法调用 my_sort($arrays,$sort_key,$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]; }else{ return false; } } }else{ return false; } array_multisort($key_arrays,$sort_order,$sort_type,$arrays); return $arrays; } }
php 2D Array deduplication method
PHP two-dimensional array is cut into strings and duplicate values are removed
PHP two-dimensional array is converted into one-dimensional array Methods
The above is the detailed content of PHP two-dimensional array sorting. For more information, please follow other related articles on the PHP Chinese website!