Introduction: This is a detailed page of PHP array_multisort () usage notes. It introduces PHP, related knowledge, skills, experience, and some PHP source code.
Class = 'pingjiaf' frameborder = '0' src = 'HTTP: // biancheng.dnbc?info/pingjia.php? Id = 339823 'rolling = 'no'>?
Function bool array_multisort (array & $ arr [, mixed $ Arg = sort_asc [, mixed $ Arg = sort_regular [, mixed $...])
Parameter description: The function sorts multiple arrays or multi-dimensional arrays.
The first parameter is an array, and each subsequent parameter may be an array or the following sort order mark.
Sort_asc-default, in ascending order
Sort_desc-sort in descending order
You can specify the sorting type.
Sort_regular-default. Sort each item in the general order.
Sort_numeric-Sort each item in numerical order.
Sort_string-Sort each item in alphabetical order.
Instance Code
$ Arr1 = array ('10', 11,100,100, 'A ');
$ Arr2 = array (1, 2, 3, '2', 5 );
Array_multisort ($ arr1, $ arr2 );
Result:
$ Arr1
Array ([0] => 10 [1] => A [2] => 11 [3] => 100 [4] => 100)
# '10' is converted to an integer 10 when compared with 11,100,100, which is smaller than the other three.
# '10' is a string when 'A' is compared. Its first character '1' ASCII code value is 49 less than 'A' (ASCII value is 97 ), therefore, '10' is the minimum element.
# When 'A' is compared with the other three numbers, it is converted to an integer 0, which is smaller than the other three.
$ Arr2
Array ([0] => 1 [1] => 5 [2] => 2 [3] => 2 [4] => 3)
# $ Arr2 element 1 corresponds to $ arr1 element '10', so it is in the [0] position.
# $ Arr1 [2] => 100, $ arr1 [3] => 100 corresponds to $ arr2 element 3, '2' respectively '. 3 is greater than '2'. Therefore, the subscript corresponding to $ arr1 [2] => 100 after sorting is
3. The subscript of $ arr1 [3] => 100 sorting is 4.
Summary
1. The number of elements in the array to be sorted must be consistent.
2. The position of the elements in the sorting array corresponds to, for example, '10' => 1, 11 => 2.
3. The back array is sorted based on the order of the front array.
4. In case of equal elements, the array of the front edge compares the Array
Love J2EE follow Java Michael Jackson video station JSON online tools
Http://biancheng.dnbcw.info/php/339823.html pageno: 7.