Php-Arrays function-array_multisort-sort multiple Arrays or multi-dimensional Arrays _ PHP Tutorial

Source: Internet
Author: User
Php-Arrays function-array_multisort-sorts multiple Arrays or multi-dimensional Arrays. Array_multisort () sorts multiple arrays or multi-dimensional arrays [function] This function can be used to sort multiple arrays at a time, or array_multisort () sorts multiple arrays or multi-dimensional arrays.

[Function]
This function can be used to sort multiple arrays at a time, or to sort multi-dimensional arrays based on one or more dimensions.
Scope of use]
Php4, php5.
[Use]
Bool array_multisort (array array1 [, mixed array2 [, mixed... [, array...])
Arrayn/required/array to be sorted
The remaining parameters are arrays or flags.
Sort SORT_ASC in ascending order
Sort SORT_DESC in descending order
SORT_REGULAR compares projects according to the common method
SORT_NUMERIC compares projects by numerical values
SORT_STRING is used to compare items by string
You cannot specify the same sort flag after each array.
The sorting flag specified behind each array is only valid for this array. prior to this, the default values are SORT_ASC and SORT_REGULAR.
[Example]
[Php]
$ Arr1 = array ("ten", 100,100, "");
$ Arr2 = array (1, 3, "2", 1 );
Array_multisort ($ arr1, $ arr2 );
Var_dump ($ arr1 );
Var_dump ($ arr2 );
/*
Array (4 ){
[0] =>
String (2) "10"
[1] =>
String (1) ""
[2] =>
Int (100)
[3] =>
Int (100)
}
Array (4 ){
[0] =>
Int (1)
[1] =>
Int (1)
[2] =>
String (1) "2"
[3] =>
Int (3)
}
*/


Taken from zuodefeng's note

Http://www.bkjia.com/PHPjc/478217.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/478217.htmlTechArticlearray_multisort () to sort multiple arrays or multi-dimensional arrays [function] This function can be used to sort multiple arrays at a time, or according to a one-dimensional or multi-dimensional array...

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.