3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $data[] = array('volume' => 67, 'edition' => 2); $data[] = array('volume' => 86, 'edition' => 1); $data[] = array('volume' => 85, 'edition' => 6); $data[] = array('volume' => 98, 'edition' => 2); $data[] = array('volume' => 86, 'edition' => 6); $data[] = array('volume' => 67, 'edition' => 7); foreach ($data as $key => $row) { $volume[$key] = $row['volume']; $edition[$key] = $row['edition']; } // Sort the data with volume descending, edition ascending // Add $data as the last parameter, to sort by the common key array_multisort($volume, SORT_DESC, $edition, SORT_ASC, $data); print_r($volume); print_r($edition); print_r($data); ?>
Output for 4.3.0 - 7.1.0
Array ( [0] => 98 [1] => 86 [2] => 86 [3] => 85 [4] => 67 [5] => 67 ) Array ( [0] => 2 [1] => 1 [2] => 6 [3] => 6 [4] => 2 [5] => 7 ) Array ( [0] => Array ( [volume] => 98 [edition] => 2 ) [1] => Array ( [volume] => 86 [edition] => 1 ) [2] => Array ( [volume] => 86 [edition] => 6 ) [3] => Array ( [volume] => 85 [edition] => 6 ) [4] => Array ( [volume] => 67 [edition] => 2 ) [5] => Array ( [volume] => 67 [edition] => 7 ) )