3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = array( [ "unix" => 1556547761, // notice the two duplicate unix values "random" => 4 ], [ "unix" => 1556547761, "random" => 2 ], [ "unix" => 1556547769, "random" => 5 ], [ "unix" => 1556547765, // this should be in the 3rd position "random" => 9 ] ); function cmpByUnix($a, $b) { return $a["unix"] - $b["unix"]; } usort($array, "cmpByUnix"); print_r($array);
Output for 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.7
Array ( [0] => Array ( [unix] => 1556547761 [random] => 4 ) [1] => Array ( [unix] => 1556547761 [random] => 2 ) [2] => Array ( [unix] => 1556547765 [random] => 9 ) [3] => Array ( [unix] => 1556547769 [random] => 5 ) )

preferences:
158.78 ms | 404 KiB | 211 Q