3v4l.org

run code in 300+ PHP versions simultaneously
<?php $timeslots = ["01:00","01:30","02:00","02:30","00:30","01:00","01:30","02:00","02:30","03:50", "14:00", "15:00", "15:30"]; sort($timeslots); // first we sort the array, very important $expected_time = "04:00"; $timestamp = strtotime($expected_time); $diff = PHP_INT_MAX; $index = null; foreach ($timeslots as $key => $time) { $currDiff = $timestamp - strtotime($time); // Add a condition to check if the difference was negative or not - because it'll only be the "next" hour when the difference is negative if ($currDiff < $diff && $currDiff < 0) { $index = $key; $diff = $currDiff; break; } } if(!is_null($index)) echo $timeslots[$index]; else echo 'Not found';

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
8.4.130.0080.01319.61
8.4.120.0060.00420.70
8.4.110.0050.00420.55
8.4.100.0110.00918.97
8.4.90.0140.00620.54
8.4.80.0050.00318.14
8.4.70.0050.00318.28
8.4.60.0120.01118.75
8.4.50.0070.00220.02
8.4.40.0180.00317.84
8.4.30.0160.00020.68
8.4.20.0050.00319.98
8.4.10.0060.01020.70
8.3.260.0100.00916.81
8.3.250.0130.00519.02
8.3.240.0120.00618.86
8.3.230.0130.00616.88
8.3.220.0120.00618.97
8.3.210.0040.00316.84
8.3.200.0060.00316.61
8.3.190.0110.00817.31
8.3.180.0120.00718.56
8.3.170.0070.01018.83
8.3.160.0130.00716.64
8.3.150.0000.01018.76
8.3.140.0080.00018.90
8.3.130.0080.00018.62
8.3.120.0000.00820.73
8.3.110.0060.00320.94
8.3.100.0150.00316.67
8.3.90.0060.01226.77
8.3.80.0060.00319.36
8.3.70.0080.00816.75
8.3.60.0120.00616.63
8.3.50.0130.00723.63
8.3.40.0130.00722.04
8.3.30.0070.00718.81
8.3.20.0030.00624.18
8.3.10.0080.00024.66
8.3.00.0000.00726.16
8.2.290.0140.00520.43
8.2.280.0110.00718.14
8.2.270.0120.00617.48
8.2.260.0070.01118.75
8.2.250.0000.00816.76
8.2.240.0060.00317.10
8.2.230.0100.00022.58
8.2.220.0040.00424.06
8.2.210.0040.00426.77
8.2.200.0060.00318.88
8.2.190.0120.00317.00
8.2.180.0030.01225.92
8.2.170.0120.00919.07
8.2.160.0070.00722.96
8.2.150.0000.00725.66
8.2.140.0080.00024.66
8.2.130.0080.00026.16
8.2.120.0040.00426.35
8.2.110.0090.00020.94
8.2.100.0130.00317.84
8.2.90.0050.00317.75
8.2.80.0040.00419.16
8.2.70.0030.00617.75
8.2.60.0040.00417.75
8.2.50.0030.00618.10
8.2.40.0000.00919.60
8.2.30.0040.00419.45
8.2.20.0000.00718.20
8.2.10.0050.00219.44
8.2.00.0000.00819.35
8.1.330.0090.00922.00
8.1.320.0110.00916.28
8.1.310.0070.01016.81
8.1.300.0090.00918.16
8.1.290.0030.00630.84
8.1.280.0080.00625.92
8.1.270.0060.00324.66
8.1.260.0060.00328.09
8.1.250.0030.00728.09
8.1.240.0030.00619.15
8.1.230.0120.00022.69
8.1.220.0040.00418.80
8.1.210.0000.00818.77
8.1.200.0000.01017.50
8.1.190.0060.00317.35
8.1.180.0040.00418.10
8.1.170.0000.00818.59
8.1.160.0000.00719.11
8.1.150.0070.00019.01
8.1.140.0000.00718.92
8.1.130.0000.00720.15
8.1.120.0050.00217.71
8.1.110.0050.00217.57
8.1.100.0000.00717.66
8.1.90.0050.00317.66
8.1.80.0000.01017.54
8.1.70.0050.00317.52
8.1.60.0050.00317.71
8.1.50.0000.00917.64
8.1.40.0050.00317.65
8.1.30.0040.00417.71
8.1.20.0040.00417.66
8.1.10.0040.00417.70
8.1.00.0080.00317.72
8.0.300.0000.00718.77
8.0.290.0000.00817.13
8.0.280.0040.00418.58
8.0.270.0040.00417.09
8.0.260.0000.00618.53
8.0.250.0070.00017.25
8.0.240.0060.00017.23
8.0.230.0000.00717.11
8.0.220.0000.00717.19
8.0.210.0030.00717.07
8.0.200.0050.00317.16
8.0.190.0040.00417.05
8.0.180.0030.00517.02
8.0.170.0060.00317.08
8.0.160.0000.00717.01
8.0.150.0050.00217.02
8.0.140.0040.00416.93
8.0.130.0030.00313.53
8.0.120.0000.00816.99
8.0.110.0030.00616.87
8.0.100.0050.00317.16
8.0.90.0000.00716.89
8.0.80.0070.01117.11
8.0.70.0000.00816.92
8.0.60.0050.00316.88
8.0.50.0000.00717.07
8.0.30.0100.00717.23
8.0.20.0090.01117.31
8.0.10.0040.00417.07
8.0.00.0100.01016.97
7.4.330.0000.00515.55
7.4.320.0000.00616.66
7.4.300.0060.00016.64
7.4.290.0070.00416.69
7.4.280.0040.00416.73
7.4.270.0080.00016.61
7.4.260.0000.00513.34
7.4.250.0000.00716.70
7.4.240.0040.00416.67
7.4.230.0030.00316.67
7.4.220.0050.00216.71
7.4.210.0070.01116.71
7.4.200.0000.00716.55
7.4.130.0150.00616.83
7.4.120.0080.01516.57
7.4.110.0070.01716.79
7.4.100.0120.00816.84
7.4.90.0100.01016.76
7.4.80.0200.00316.65
7.4.70.0120.00616.51
7.4.60.0110.00516.64
7.4.50.0070.00716.59
7.4.40.0160.00016.93
7.4.30.0040.01116.75
7.4.20.0110.01116.50
7.4.10.0070.01016.55
7.4.00.0080.00417.45
7.3.330.0080.00016.23
7.3.320.0040.00413.34
7.3.310.0030.00316.54
7.3.300.0060.00016.36
7.3.290.0060.01216.45
7.3.260.0030.01316.37
7.3.230.0040.01216.74
7.3.220.0130.01016.71
7.3.210.0190.00016.75
7.3.200.0210.00316.82
7.3.190.0080.00816.62
7.3.180.0040.01216.70
7.3.170.0090.00716.53
7.3.160.0080.00816.49
7.3.150.0110.00516.52
7.3.140.0140.00416.40
7.3.130.0040.01216.69
7.3.120.0110.00416.52
7.3.110.0060.00916.63
7.3.100.0140.00316.51
7.3.90.0160.00316.54
7.3.80.0140.00516.56
7.3.70.0140.00816.48
7.3.60.0030.01316.38
7.3.50.0130.00716.56
7.3.40.0050.01516.53
7.3.30.0150.00616.62
7.3.20.0200.00716.66
7.3.10.0240.00616.48
7.3.00.0220.00316.59
7.2.340.0080.00916.95
7.2.330.0100.01016.71
7.2.320.0130.00616.75
7.2.310.0080.00816.79
7.2.300.0070.01016.83
7.2.290.0120.00516.61
7.2.280.0070.01016.80
7.2.270.0080.00816.93
7.2.260.0120.00316.79
7.2.250.0030.01316.72
7.2.240.0000.01816.89
7.2.230.0110.00616.54
7.2.220.0150.00616.65
7.2.210.0100.01016.84
7.2.200.0210.00016.92
7.2.190.0130.00816.75
7.2.180.0130.00816.77
7.2.170.0190.00616.80
7.2.160.0130.00816.78
7.2.150.0200.01016.86
7.2.140.0150.01416.70
7.2.130.0130.01316.84
7.2.120.0150.01316.70
7.2.110.0190.00016.84
7.2.100.0170.01016.81
7.2.90.0110.01116.94
7.2.80.0070.01616.86
7.2.70.0140.00616.77
7.2.60.0170.00716.87
7.2.50.0150.00816.94
7.2.40.0460.00316.88
7.2.30.0140.00716.92
7.2.20.0190.00516.79
7.2.10.0130.00816.80
7.2.00.0060.01216.86

preferences:
119.33 ms | 403 KiB | 5 Q