3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $a = array( array( 'label' => 'AA', 'start' => '2015-09-05 14:14:14' ), array( 'label' => 'DD', 'start' => '2015-09-14 14:14:14' ), array( 'label' => 'EE', 'start' => '2016-09-05 14:14:14' ), array( 'label' => 'BB', 'start' => '2015-09-08 00:00:00' ), array( 'label' => 'CC', 'start' => '2015-09-08 01:14:14' ), ); usort($a, function($a, $b) { $a = strtotime($a); $b = strtotime($b); if ($a == $b) { return 0; } return ($a < $b) ? -1 : 1; }); var_dump($a);
Output for 7.0.0 - 7.2.0
Warning: strtotime() expects parameter 1 to be string, array given in /in/AqZGY on line 26 Warning: strtotime() expects parameter 1 to be string, array given in /in/AqZGY on line 27 Warning: strtotime() expects parameter 1 to be string, array given in /in/AqZGY on line 26 Warning: strtotime() expects parameter 1 to be string, array given in /in/AqZGY on line 27 Warning: strtotime() expects parameter 1 to be string, array given in /in/AqZGY on line 26 Warning: strtotime() expects parameter 1 to be string, array given in /in/AqZGY on line 27 Warning: strtotime() expects parameter 1 to be string, array given in /in/AqZGY on line 26 Warning: strtotime() expects parameter 1 to be string, array given in /in/AqZGY on line 27 array(5) { [0]=> array(2) { ["label"]=> string(2) "AA" ["start"]=> string(19) "2015-09-05 14:14:14" } [1]=> array(2) { ["label"]=> string(2) "DD" ["start"]=> string(19) "2015-09-14 14:14:14" } [2]=> array(2) { ["label"]=> string(2) "EE" ["start"]=> string(19) "2016-09-05 14:14:14" } [3]=> array(2) { ["label"]=> string(2) "BB" ["start"]=> string(19) "2015-09-08 00:00:00" } [4]=> array(2) { ["label"]=> string(2) "CC" ["start"]=> string(19) "2015-09-08 01:14:14" } }
Output for 5.4.0 - 5.6.28
Warning: strtotime() expects parameter 1 to be string, array given in /in/AqZGY on line 26 Warning: strtotime() expects parameter 1 to be string, array given in /in/AqZGY on line 27 Warning: strtotime() expects parameter 1 to be string, array given in /in/AqZGY on line 26 Warning: strtotime() expects parameter 1 to be string, array given in /in/AqZGY on line 27 Warning: strtotime() expects parameter 1 to be string, array given in /in/AqZGY on line 26 Warning: strtotime() expects parameter 1 to be string, array given in /in/AqZGY on line 27 Warning: strtotime() expects parameter 1 to be string, array given in /in/AqZGY on line 26 Warning: strtotime() expects parameter 1 to be string, array given in /in/AqZGY on line 27 Warning: strtotime() expects parameter 1 to be string, array given in /in/AqZGY on line 26 Warning: strtotime() expects parameter 1 to be string, array given in /in/AqZGY on line 27 Warning: strtotime() expects parameter 1 to be string, array given in /in/AqZGY on line 26 Warning: strtotime() expects parameter 1 to be string, array given in /in/AqZGY on line 27 array(5) { [0]=> array(2) { ["label"]=> string(2) "CC" ["start"]=> string(19) "2015-09-08 01:14:14" } [1]=> array(2) { ["label"]=> string(2) "BB" ["start"]=> string(19) "2015-09-08 00:00:00" } [2]=> array(2) { ["label"]=> string(2) "EE" ["start"]=> string(19) "2016-09-05 14:14:14" } [3]=> array(2) { ["label"]=> string(2) "DD" ["start"]=> string(19) "2015-09-14 14:14:14" } [4]=> array(2) { ["label"]=> string(2) "AA" ["start"]=> string(19) "2015-09-05 14:14:14" } }