3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $data = [ 0 => [ 'SMITH1', 'SMITH2', 'SMITH3', 'SMITH4', ], 1 =>[ 'JOHN1', 'JOHN2', 'JOHN3', 'JOHN4', ] ]; $newArr = []; foreach ($data[0] as $k=>$v){ $newArr[] = [ 'fname' => $v, 'lname' => $data[1][$k] ]; unset($data[0][$k]); unset($data[1][$k]); } array_multisort( array_column($newArr, 'fname'), SORT_ASC, array_column($newArr, 'lname'), SORT_ASC, $newArr ); print_r($newArr);
based on 5henP
Output for 5.6.0 - 5.6.30, hhvm-3.15.4, 7.0.0 - 7.2.0
Array ( [0] => Array ( [fname] => SMITH1 [lname] => JOHN1 ) [1] => Array ( [fname] => SMITH2 [lname] => JOHN2 ) [2] => Array ( [fname] => SMITH3 [lname] => JOHN3 ) [3] => Array ( [fname] => SMITH4 [lname] => JOHN4 ) )