3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = [ 1 => [ 'Date' => '2015-11-04' ], 2 => [ 'Date' => '2015-11-05' ] ]; uksort($arr,'mySortDate'); function mySortDate($a,$b) { $aDate = strtotime($a['Date']); $bDate = strtotime($b['Date']); if ($aDate == $bDate) { return 0; } return ($aDate < $bDate) ? -1 : 1; } print "<pre>"; var_dump($arr);
Output for 8.3.0 - 8.3.4
Warning: Trying to access array offset on int in /in/rTXCO on line 17 Deprecated: strtotime(): Passing null to parameter #1 ($datetime) of type string is deprecated in /in/rTXCO on line 17 Warning: Trying to access array offset on int in /in/rTXCO on line 18 Deprecated: strtotime(): Passing null to parameter #1 ($datetime) of type string is deprecated in /in/rTXCO on line 18 <pre>array(2) { [1]=> array(1) { ["Date"]=> string(10) "2015-11-04" } [2]=> array(1) { ["Date"]=> string(10) "2015-11-05" } }
Output for 8.1.0 - 8.1.27, 8.2.0 - 8.2.17
Warning: Trying to access array offset on value of type int in /in/rTXCO on line 17 Deprecated: strtotime(): Passing null to parameter #1 ($datetime) of type string is deprecated in /in/rTXCO on line 17 Warning: Trying to access array offset on value of type int in /in/rTXCO on line 18 Deprecated: strtotime(): Passing null to parameter #1 ($datetime) of type string is deprecated in /in/rTXCO on line 18 <pre>array(2) { [1]=> array(1) { ["Date"]=> string(10) "2015-11-04" } [2]=> array(1) { ["Date"]=> string(10) "2015-11-05" } }
Output for 8.0.0 - 8.0.30
Warning: Trying to access array offset on value of type int in /in/rTXCO on line 17 Warning: Trying to access array offset on value of type int in /in/rTXCO on line 18 <pre>array(2) { [1]=> array(1) { ["Date"]=> string(10) "2015-11-04" } [2]=> array(1) { ["Date"]=> string(10) "2015-11-05" } }
Output for 7.4.0 - 7.4.33
Notice: Trying to access array offset on value of type int in /in/rTXCO on line 17 Notice: Trying to access array offset on value of type int in /in/rTXCO on line 18 <pre>array(2) { [1]=> array(1) { ["Date"]=> string(10) "2015-11-04" } [2]=> array(1) { ["Date"]=> string(10) "2015-11-05" } }
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33
<pre>array(2) { [1]=> array(1) { ["Date"]=> string(10) "2015-11-04" } [2]=> array(1) { ["Date"]=> string(10) "2015-11-05" } }
Output for 5.5.24 - 5.5.35, 5.6.8 - 5.6.28
<pre>array(2) { [2]=> array(1) { ["Date"]=> string(10) "2015-11-05" } [1]=> array(1) { ["Date"]=> string(10) "2015-11-04" } }

preferences:
179.55 ms | 402 KiB | 224 Q