3v4l.org

run code in 300+ PHP versions simultaneously
<?php $Hand = array("05h", "02h", "03c", "02s", "04h"); $Hand2 = array("05h", "02h", "03c", "02s", "03h"); $Hand3 = array("03s", "02h", "03c", "02s", "03h"); function sortMyArray(&$arr){ usort($arr, function($a,$b) { if(intval($a) == intval($b)){ return 0; } return 1; }); return $arr; } print_R(sortMyArray($Hand)); print_R(sortMyArray($Hand2)); print_R(sortMyArray($Hand3));

preferences:
20.38 ms | 405 KiB | 5 Q