3v4l.org

run code in 300+ PHP versions simultaneously
<?php $fruits[0]["expiryDate"] = "20142646"; $fruits[1]["expiryDate"] = "20142643"; $fruits[2]["expiryDate"] = "201426445"; usort($fruits, "compareDates"); print_r($fruits); function compareDates($a, $b) { $t1 = strtotime($a['expiryDate']); $t2 = strtotime($b['expiryDate']); if ( $t1 == $t2) { return 0; } return ( $t1 > $t2) ? +1 : -1; }

preferences:
47.8 ms | 402 KiB | 5 Q