Go deep into the arraymultisort sorting principle. Copy the code as follows :? Php $ data [] array (volume67, edition2); $ data [] array (volume86, edition1); $ data [] array (volume85, edition6); $ data []
The code is as follows:
$ Data [] = array ('Volume '=> 67, 'version' => 2 );
$ Data [] = array ('Volume '=> 86, 'version' => 1 );
$ Data [] = array ('Volume '=> 85, 'version' => 6 );
$ Data [] = array ('Volume '=> 98, 'version' => 2 );
$ Data [] = array ('Volume '=> 86, 'version' => 6 );
$ Data [] = array ('Volume '=> 67, 'version' => 7 );
?>
The code is as follows:
$ A = array (1, 2, 3 );
$ B = array (3 );
// Sort data by volume in descending order and edition in ascending order
// Use $ data as the last parameter and sort it by a common key
Array_multisort ($ a, $ B, $ data); // The number of arrays in one dimension is different.
Var_dump ($ data );
?>
The above test code prompts the number of inconsistent arrays
Warning: Array_multisort (): Array sizes are inconsistent in
G: \ www \ test \ index. phpOn line
15
Check again
The code is as follows:
$ Data [] = array ('Volume '=> 67, 'version' => 2 );
$ Data [] = array ('Volume '=> 86, 'version' => 1 );
$ Data [] = array ('Volume '=> 85, 'version' => 6 );
$ Data [] = array ('Volume '=> 98, 'version' => 2 );
$ Data [] = array ('Volume '=> 86, 'version' => 6 );
$ Data [] = array ('Volume '=> 67, 'version' => 7, 3, 4, 4); // Two-dimensional numbers are different.
?>
The code is as follows:
$ A = array );
$ B = array (3, 3, 3, 3, 3 );
// The array (, 7, 3, 4) corresponding to 11 appears in the same order;
// Sort data by volume in descending order and edition in ascending order
// Use $ data as the last parameter and sort it by a common key
Array_multisort ($ a, $ B, $ data );
Var_dump ($ a, $ data );
?>
The above results show that:
The array parameters must have the same number of one dimensions;
Then the corresponding position of each array (note that it is not the same key, but corresponds to a natural location, for example, $ a (1 => 4), corresponding to $ B (99 => 4) because they are in the first position, rather than the key () ING), the values in the corresponding positions are the same as those in the equal bamboo, when one of the preceding values needs to be adjusted, other values on the same bamboo are moved vertically.
Class:
$ A $ B $ c
4 => 7 8 => 10 '000000' => 0
9 => 9 0 => 1 999 => 9
0 => 2 9 => 3 9999 => 7
----------------------
If you change the value by 7 and 9 of $ a, the 10 and 1 of $ B will change to 0 and 9 of $ c.
So the relationship is like the above three arrays, with the same color on the same "front", one of which is changed, and everyone needs to change the location together.
The http://www.bkjia.com/PHPjc/327698.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/327698.htmlTechArticle code is as follows :? Php $ data [] = array ('Volume '= 67, 'version' = 2); $ data [] = array ('Volume' = 86, 'version' = 1); $ data [] = array ('Volume '= 85, 'version' = 6); $ data []...