3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $fruits[0]["expiryDate"] = "20142646"; $fruits[1]["expiryDate"] = "20142643"; $fruits[2]["expiryDate"] = "201426445"; usort($fruits, "compareDates"); print_r($fruits); function compareDates($a, $b) { if (!(isset($a['expiryDate']) && isset($b['expiryDate']))) { return false; } $t1 = strtotime($a['expiryDate']); $t2 = strtotime($b['expiryDate']); return $t1 - $t2; }
based on peB2B
Output for hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
Array ( [0] => Array ( [expiryDate] => 20142646 ) [1] => Array ( [expiryDate] => 20142643 ) [2] => Array ( [expiryDate] => 201426445 ) )
Output for 5.1.0 - 5.6.28
Array ( [0] => Array ( [expiryDate] => 201426445 ) [1] => Array ( [expiryDate] => 20142643 ) [2] => Array ( [expiryDate] => 20142646 ) )
Output for 4.3.0 - 5.0.5
Array ( [0] => Array ( [expiryDate] => 20142643 ) [1] => Array ( [expiryDate] => 20142646 ) [2] => Array ( [expiryDate] => 201426445 ) )