Discover sort multidimensional array, include the articles, news, trends, analysis and practical advice about sort multidimensional array on alibabacloud.com
In actual development, more or less will encounter array sorting problem, in addition to the conventional write simple sorting algorithm, PHP also provides a built-in array sorting function, this time to share the key: Uasort Use user-defined
For example, I have a multidimensional array $relationshop_list, which has IDs, with sort two columns, and I want the array to be sorted in descending order of ID, sorted in sort of way:Sort$array _field = Array_column ($relationshop _list, ' sort ')
PHP uses Array_multisort to sort multiple arrays or multidimensional arrays, and the PHP multidimensional array is sorted
PHP Array_multisort can be used to sort multiple arrays at once, or to sort multidimensional arrays based on one dimension or
Sorting 2-D arrays or multidimensional arrays is a common problem, in PHP we have a special multidimensional array sorting function, the following briefly:Array_multisort (array1,sorting order, sorting type,array2,array3. is a function that sorts
Array_multisort () can be used to sort multiple arrays at once, or to sort multidimensional arrays based on one dimension or multidimensional.
array_multisort-to sort multiple arrays or multidimensional arraysDescriptionBOOL Array_multisort (array
1. Initialization of arrays(1) Create an array with arrayA: $products = array (' tires ', ' oil ', ' Spark plugs ');Array () is actually a language structure, not a function
B: Initializing the related array$prices = Array (' Tires ' =>100, ' oil ' =
first, see the simplest situation. There are two arrays:$arr 1 = Array (1, 9, 5);$arr 2 = Array (6, 2, 4);Array_multisort ($arr 1, $arr 2);Print_r ($arr 1); The order to get is 1,5,9Print_r ($arr 2); The order to get is 6,4,2I estimate that the
array_multisort-to sort multiple arrays or multidimensional arrays, arraymultisort multidimensional
array_multisort-sorting multiple arrays or multidimensional arrays successfully returns true otherwise false
The input array is treated as a column
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.