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[$key]); $t2 = strtotime($b[$key]); return $t1 - $t2; } usort($array, 'date_compare'); var_dump($array);
Output for 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" } } Notice: Undefined variable: key in /in/8uk91 on line 8 Notice: Undefined index: in /in/8uk91 on line 8 Notice: Undefined variable: key in /in/8uk91 on line 9 Notice: Undefined index: in /in/8uk91 on line 9 Notice: Undefined variable: key in /in/8uk91 on line 8 Notice: Undefined index: in /in/8uk91 on line 8 Notice: Undefined variable: key in /in/8uk91 on line 9 Notice: Undefined index: in /in/8uk91 on line 9 Notice: Undefined variable: key in /in/8uk91 on line 8 Notice: Undefined index: in /in/8uk91 on line 8 Notice: Undefined variable: key in /in/8uk91 on line 9 Notice: Undefined index: in /in/8uk91 on line 9 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" } }
Output for hhvm-3.10.0 - 3.12.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" } } Notice: Undefined index: in /in/8uk91 on line 8 Notice: Undefined index: in /in/8uk91 on line 9 Notice: Undefined index: in /in/8uk91 on line 8 Notice: Undefined index: in /in/8uk91 on line 9 Notice: Undefined index: in /in/8uk91 on line 8 Notice: Undefined index: in /in/8uk91 on line 9 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" } }
Output for 5.3.0 - 5.6.28
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" } } Notice: Undefined variable: key in /in/8uk91 on line 8 Notice: Undefined index: in /in/8uk91 on line 8 Notice: Undefined variable: key in /in/8uk91 on line 9 Notice: Undefined index: in /in/8uk91 on line 9 Notice: Undefined variable: key in /in/8uk91 on line 8 Notice: Undefined index: in /in/8uk91 on line 8 Notice: Undefined variable: key in /in/8uk91 on line 9 Notice: Undefined index: in /in/8uk91 on line 9 Notice: Undefined variable: key in /in/8uk91 on line 8 Notice: Undefined index: in /in/8uk91 on line 8 Notice: Undefined variable: key in /in/8uk91 on line 9 Notice: Undefined index: in /in/8uk91 on line 9 Notice: Undefined variable: key in /in/8uk91 on line 8 Notice: Undefined index: in /in/8uk91 on line 8 Notice: Undefined variable: key in /in/8uk91 on line 9 Notice: Undefined index: in /in/8uk91 on line 9 array(4) { [0]=> array(2) { ["date"]=> string(10) "2014-03-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) "2013-12-01" ["price"]=> string(6) "123.00" } [3]=> array(2) { ["date"]=> string(10) "2014-12-01" ["price"]=> string(6) "123.00" } }
Output for 5.1.0 - 5.2.17
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" } } Notice: Undefined variable: key in /in/8uk91 on line 8 Notice: Undefined index: in /in/8uk91 on line 8 Notice: Undefined variable: key in /in/8uk91 on line 9 Notice: Undefined index: in /in/8uk91 on line 9 Notice: Undefined variable: key in /in/8uk91 on line 8 Notice: Undefined index: in /in/8uk91 on line 8 Notice: Undefined variable: key in /in/8uk91 on line 9 Notice: Undefined index: in /in/8uk91 on line 9 Notice: Undefined variable: key in /in/8uk91 on line 8 Notice: Undefined index: in /in/8uk91 on line 8 Notice: Undefined variable: key in /in/8uk91 on line 9 Notice: Undefined index: in /in/8uk91 on line 9 Notice: Undefined variable: key in /in/8uk91 on line 8 Notice: Undefined index: in /in/8uk91 on line 8 Notice: Undefined variable: key in /in/8uk91 on line 9 Notice: Undefined index: in /in/8uk91 on line 9 array(4) { [0]=> array(2) { ["date"]=> string(10) "2014-03-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) "2013-12-01" ["price"]=> string(6) "123.00" } [3]=> array(2) { ["date"]=> string(10) "2014-12-01" ["price"]=> string(6) "123.00" } }
Output for 5.0.4 - 5.0.5
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" } } Notice: Undefined variable: key in /in/8uk91 on line 8 Notice: Undefined index: in /in/8uk91 on line 8 Warning: strtotime(): Called with an empty time parameter. in /in/8uk91 on line 8 Notice: Undefined variable: key in /in/8uk91 on line 9 Notice: Undefined index: in /in/8uk91 on line 9 Warning: strtotime(): Called with an empty time parameter. in /in/8uk91 on line 9 Notice: Undefined variable: key in /in/8uk91 on line 8 Notice: Undefined index: in /in/8uk91 on line 8 Warning: strtotime(): Called with an empty time parameter. in /in/8uk91 on line 8 Notice: Undefined variable: key in /in/8uk91 on line 9 Notice: Undefined index: in /in/8uk91 on line 9 Warning: strtotime(): Called with an empty time parameter. in /in/8uk91 on line 9 Notice: Undefined variable: key in /in/8uk91 on line 8 Notice: Undefined index: in /in/8uk91 on line 8 Warning: strtotime(): Called with an empty time parameter. in /in/8uk91 on line 8 Notice: Undefined variable: key in /in/8uk91 on line 9 Notice: Undefined index: in /in/8uk91 on line 9 Warning: strtotime(): Called with an empty time parameter. in /in/8uk91 on line 9 Notice: Undefined variable: key in /in/8uk91 on line 8 Notice: Undefined index: in /in/8uk91 on line 8 Warning: strtotime(): Called with an empty time parameter. in /in/8uk91 on line 8 Notice: Undefined variable: key in /in/8uk91 on line 9 Notice: Undefined index: in /in/8uk91 on line 9 Warning: strtotime(): Called with an empty time parameter. in /in/8uk91 on line 9 array(4) { [0]=> array(2) { ["date"]=> string(10) "2014-03-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) "2013-12-01" ["price"]=> string(6) "123.00" } [3]=> array(2) { ["date"]=> string(10) "2014-12-01" ["price"]=> string(6) "123.00" } }
Output for 5.0.1 - 5.0.3
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" } } Notice: Undefined variable: key in /in/8uk91 on line 8 Notice: Undefined index: in /in/8uk91 on line 8 Warning: strtotime(): Called with an empty time parameter. in /in/8uk91 on line 8 Notice: Undefined variable: key in /in/8uk91 on line 9 Notice: Undefined index: in /in/8uk91 on line 9 Warning: strtotime(): Called with an empty time parameter. in /in/8uk91 on line 9 Notice: Undefined variable: key in /in/8uk91 on line 8 Notice: Undefined index: in /in/8uk91 on line 8 Warning: strtotime(): Called with an empty time parameter. in /in/8uk91 on line 8 Notice: Undefined variable: key in /in/8uk91 on line 9 Notice: Undefined index: in /in/8uk91 on line 9 Warning: strtotime(): Called with an empty time parameter. in /in/8uk91 on line 9 Notice: Undefined variable: key in /in/8uk91 on line 8 Notice: Undefined index: in /in/8uk91 on line 8 Warning: strtotime(): Called with an empty time parameter. in /in/8uk91 on line 8 Notice: Undefined variable: key in /in/8uk91 on line 9 Notice: Undefined index: in /in/8uk91 on line 9 Warning: strtotime(): Called with an empty time parameter. in /in/8uk91 on line 9 Notice: Undefined variable: key in /in/8uk91 on line 8 Notice: Undefined index: in /in/8uk91 on line 8 Warning: strtotime(): Called with an empty time parameter. in /in/8uk91 on line 8 Notice: Undefined variable: key in /in/8uk91 on line 9 Notice: Undefined index: in /in/8uk91 on line 9 Warning: strtotime(): Called with an empty time parameter. in /in/8uk91 on line 9 array(4) { [0]=> array(2) { ["date"]=> string(10) "2014-03-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) "2013-12-01" ["price"]=> string(6) "123.00" } [3]=> array(2) { ["date"]=> string(10) "2014-12-01" ["price"]=> string(6) "123.00" } }
Output for 4.3.2 - 5.0.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" } } Notice: Undefined variable: key in /in/8uk91 on line 8 Notice: Undefined index: in /in/8uk91 on line 8 Notice: strtotime(): Called with empty time parameter in /in/8uk91 on line 8 Notice: Undefined variable: key in /in/8uk91 on line 9 Notice: Undefined index: in /in/8uk91 on line 9 Notice: strtotime(): Called with empty time parameter in /in/8uk91 on line 9 Notice: Undefined variable: key in /in/8uk91 on line 8 Notice: Undefined index: in /in/8uk91 on line 8 Notice: strtotime(): Called with empty time parameter in /in/8uk91 on line 8 Notice: Undefined variable: key in /in/8uk91 on line 9 Notice: Undefined index: in /in/8uk91 on line 9 Notice: strtotime(): Called with empty time parameter in /in/8uk91 on line 9 Notice: Undefined variable: key in /in/8uk91 on line 8 Notice: Undefined index: in /in/8uk91 on line 8 Notice: strtotime(): Called with empty time parameter in /in/8uk91 on line 8 Notice: Undefined variable: key in /in/8uk91 on line 9 Notice: Undefined index: in /in/8uk91 on line 9 Notice: strtotime(): Called with empty time parameter in /in/8uk91 on line 9 Notice: Undefined variable: key in /in/8uk91 on line 8 Notice: Undefined index: in /in/8uk91 on line 8 Notice: strtotime(): Called with empty time parameter in /in/8uk91 on line 8 Notice: Undefined variable: key in /in/8uk91 on line 9 Notice: Undefined index: in /in/8uk91 on line 9 Notice: strtotime(): Called with empty time parameter in /in/8uk91 on line 9 array(4) { [0]=> array(2) { ["date"]=> string(10) "2014-03-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) "2013-12-01" ["price"]=> string(6) "123.00" } [3]=> array(2) { ["date"]=> string(10) "2014-12-01" ["price"]=> string(6) "123.00" } }
Output for 4.3.0 - 4.3.1
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" } } Notice: Undefined variable: key in /in/8uk91 on line 8 Notice: Undefined index: in /in/8uk91 on line 8 Notice: strtotime() [http://www.php.net/function.strtotime]: Called with empty time parameter in /in/8uk91 on line 8 Notice: Undefined variable: key in /in/8uk91 on line 9 Notice: Undefined index: in /in/8uk91 on line 9 Notice: strtotime() [http://www.php.net/function.strtotime]: Called with empty time parameter in /in/8uk91 on line 9 Notice: Undefined variable: key in /in/8uk91 on line 8 Notice: Undefined index: in /in/8uk91 on line 8 Notice: strtotime() [http://www.php.net/function.strtotime]: Called with empty time parameter in /in/8uk91 on line 8 Notice: Undefined variable: key in /in/8uk91 on line 9 Notice: Undefined index: in /in/8uk91 on line 9 Notice: strtotime() [http://www.php.net/function.strtotime]: Called with empty time parameter in /in/8uk91 on line 9 Notice: Undefined variable: key in /in/8uk91 on line 8 Notice: Undefined index: in /in/8uk91 on line 8 Notice: strtotime() [http://www.php.net/function.strtotime]: Called with empty time parameter in /in/8uk91 on line 8 Notice: Undefined variable: key in /in/8uk91 on line 9 Notice: Undefined index: in /in/8uk91 on line 9 Notice: strtotime() [http://www.php.net/function.strtotime]: Called with empty time parameter in /in/8uk91 on line 9 Notice: Undefined variable: key in /in/8uk91 on line 8 Notice: Undefined index: in /in/8uk91 on line 8 Notice: strtotime() [http://www.php.net/function.strtotime]: Called with empty time parameter in /in/8uk91 on line 8 Notice: Undefined variable: key in /in/8uk91 on line 9 Notice: Undefined index: in /in/8uk91 on line 9 Notice: strtotime() [http://www.php.net/function.strtotime]: Called with empty time parameter in /in/8uk91 on line 9 array(4) { [0]=> array(2) { ["date"]=> string(10) "2014-03-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) "2013-12-01" ["price"]=> string(6) "123.00" } [3]=> array(2) { ["date"]=> string(10) "2014-12-01" ["price"]=> string(6) "123.00" } }