3v4l.org

run code in 300+ PHP versions simultaneously
<?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 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Fatal error: Uncaught TypeError: strtotime(): Argument #1 ($datetime) must be of type string, array given in /in/AqZGY:26 Stack trace: #0 /in/AqZGY(26): strtotime(Array) #1 [internal function]: {closure}(Array, Array) #2 /in/AqZGY(25): usort(Array, Object(Closure)) #3 {main} thrown in /in/AqZGY on line 26
Process exited with code 255.
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28
Fatal error: Uncaught TypeError: strtotime(): Argument #1 ($datetime) must be of type string, array given in /in/AqZGY:26 Stack trace: #0 /in/AqZGY(26): strtotime(Array) #1 [internal function]: {closure}(Array, Array) #2 /in/AqZGY(33): usort(Array, Object(Closure)) #3 {main} thrown in /in/AqZGY on line 26
Process exited with code 255.
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.16 - 7.3.33, 7.4.0 - 7.4.33
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.4.45, 5.5.0 - 5.5.38, 5.6.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" } }

preferences:
232.49 ms | 406 KiB | 272 Q