This article mainly introduces a simple example of how to sort two-dimensional arrays in PHP, and a friend in need can refer to the
This article introduces the use of the Array_multisort function in PHP for two-dimensional array ordering examples, there is a need for friends, refer to the bar. Following an article: Php two-dimensional array sorting custom function, today, we introduce a PHP two-dimensional array ordering example. PHP is a simple sort of two-dimensional array, mainly used for array_multisort functions. Example: code as follows: <?php /** * php two-dimensional array sort * Edit www.jb51.net */ $data = array (); &NB Sp $data [] = Array (' volume ' =>, ' Edition ' => 2); $data [] = Array (' volume ' => 86 , ' edition ' => 1; $data [] = Array (' volume ' =>, ' Edition ' => 6); $data [] = Array (' volume ' =>, ' Edition ' => 2); $data [] = Array (' volume ' =>), ' Edition ' => 6 ); $data [] = Array (' volume ' =>, ' edition ' => 7); //Get column list & nbsp foreach ($data as $key => $row) { $volume [$key] = $row [' Vol. Ume ']; $edition [$key] = $row [' Edition ']; } ARRAy_multisort ($volume, Sort_desc, $edition, SORT_ASC, $data); Print_r ($data); ?> output: code as follows: Array ( [0] => Array &N Bsp ( [volume] =>- &NBS P [Edition] => 2 ) [1] => Array ( [Volume] = > [Edition] => 1 &NBSP ; ) [2] => Array ( &NBS P [volume] => [Edition] => 6 &N Bsp ) [3] => Array (&NB Sp [volume] => [Edition] => 6 ) [4] => Array & nbsp ( [volume] => &NBS P [Edition] => 2 ) &NBS P [5] => Array ( [Volume] => [Edition] => 7 & nbsp ) ) Description: Array_multisort function parameters are very flexible, you can refer to the instructions in the PHP manual, in-depth study.