Copy Code code as follows:
<?php
$data [] = Array (' volume ' =>, ' Edition ' => 2);
$data [] = Array (' volume ' =>, ' edition ' => 1);
$data [] = Array (' volume ' =>, ' Edition ' => 6);
$data [] = Array (' volume ' =>, ' Edition ' => 2);
$data [] = Array (' volume ' =>, ' Edition ' => 6);
$data [] = Array (' volume ' =>, ' edition ' => 7);
?>
Copy Code code as follows:
<?php
$a = array (1,2,3);
$b = Array (3);
Arranges data in descending order according to volume, sorted by edition ascending order
Sort the $data as the last parameter in a common key
Array_multisort ($a, $b, $data);//Array One dimension number is different
Var_dump ($data);
?>
The above test code hints at the number of inconsistent arrays
<b>warning</b>: Array_multisort (): Array sizes are inconsistent in <b>g:\www\test\index.php</b > On line <b>15</b><br/>
Look again
Copy Code code as follows:
<?php
$data [] = Array (' volume ' =>, ' Edition ' => 2);
$data [] = Array (' volume ' =>, ' edition ' => 1);
$data [] = Array (' volume ' =>, ' Edition ' => 6);
$data [] = Array (' volume ' =>, ' Edition ' => 2);
$data [] = Array (' volume ' =>, ' Edition ' => 6);
$data [] = Array (' volume ' =>, ' edition ' => 7, 3, 4,4);//The number of two dimensions is different
?>
Copy Code code as follows:
<?php
$a = array (11,2,3,4,5,6);
$b = Array (3,3,3,3,3,3);
From the result, we see that the array (67,7,3,4,4) corresponding to 11 appears in the same order;
Arranges data in descending order according to volume, sorted by edition ascending order
Sort the $data as the last parameter in a common key
Array_multisort ($a, $b, $data);
Var_dump ($a, $data);
?>
from the results above you can tell:
Array parameters must have the same number of one-dimensional dimensions;
then each array corresponds to the position ( note not the same key, but from the natural position, such as $a (1=>4), corresponding to $b (99=>4) 4, because their position is the first, not the key ( 1,99), the corresponding position in the value of the same as wearing the same on each other equal bamboo poles, wearing one of the above values need to adjust position, it will cause the same "bamboo rod" other values appear vertical movement.
class:
$a $b $c
4=>7 8=>10 ' 999 ' => 0
9=>9 0=>1 999=>9
0=> 2 9=> 3 9999=>7
----------------------
If appear presses $a 7 and 9 to swap, will also drive $b 10 and 1 swap $c 0 and 9.
So the relationship is like the top three arrays, the same color on the same "front", and one of them, we want to change positions together.