array_multisort() sorts multiple arrays or multidimensional arrays
【Function】
This function can be used to sort multiple arrays at once, or to sort multi-dimensional arrays according to a certain dimension or multiple 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_ASC Sort in ascending order
SORT_DESC Sort in descending order
SORT_REGULAR is to compare items according to the usual method
SORT_NUMERIC is to compare items based on numerical value
SORT_STRING is to compare items according to strings
The same kind of sorting flag cannot be specified after each array
The sort flag specified behind each array is only valid for that array. Before that, the default values SORT_ASC and SORT_REGULAR
【Example】
[php]
$arr1 = array("10",100,100,"a");
$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) "a"
[2]=>
int(100)
[3]=>
int(100)
}
array(4) {
[0]=>
int(1)
[1]=>
int(1)
[2]=>
string(1) "2"
[3]=>
int(3)
}
*/
Excerpted from zuodefeng’s notes