3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $data[] = array('volume' => 6, 'edition' => 6); $data[] = array('volume' => 5, 'edition' => 5); $data[] = array('volume' => 4, 'edition' => 4); $data[] = array('volume' => 3, 'edition' => 3); $data[] = array('volume' => 2, 'edition' => 2); $data[] = array('volume' => 1, 'edition' => 1); // Obtain a list of columns 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($edition, SORT_ASC, $volume, SORT_DESC, $data); echo '<pre>'; print_r($volume); ?>
Output for 4.3.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
<pre>Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5 [5] => 6 )