3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $array = array(array('date'=>'2014-12-01', 'price'=>'123.00'), array('date'=>'2013-12-01', 'price'=>'123.00'), array('date'=>'2014-02-01', 'price'=>'123.00'), array('date'=>'2014-03-01', 'price'=>'123.00')); var_dump($array); function date_compare($a, $b) { $t1 = strtotime($a['date']); $t2 = strtotime($b['date']); return $t1 - $t2; } usort($array, 'date_compare'); var_dump($array);
Output for 4.3.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
array(4) { [0]=> array(2) { ["date"]=> string(10) "2014-12-01" ["price"]=> string(6) "123.00" } [1]=> array(2) { ["date"]=> string(10) "2013-12-01" ["price"]=> string(6) "123.00" } [2]=> array(2) { ["date"]=> string(10) "2014-02-01" ["price"]=> string(6) "123.00" } [3]=> array(2) { ["date"]=> string(10) "2014-03-01" ["price"]=> string(6) "123.00" } } array(4) { [0]=> array(2) { ["date"]=> string(10) "2013-12-01" ["price"]=> string(6) "123.00" } [1]=> array(2) { ["date"]=> string(10) "2014-02-01" ["price"]=> string(6) "123.00" } [2]=> array(2) { ["date"]=> string(10) "2014-03-01" ["price"]=> string(6) "123.00" } [3]=> array(2) { ["date"]=> string(10) "2014-12-01" ["price"]=> string(6) "123.00" } }