3v4l.org

run code in 300+ PHP versions simultaneously
<?php $hours = ["08:00:00", "18:00:00"]; $bookings = [["10:00:00", "15:00:00"], ["08:05:00", "09:00:00"], ["16:00:00", "17:00:00"] ]; $start = $hours[0]; $end = $hours[1]; // sort the bookings $bstart = array_column($bookings, 0); array_multisort($bstart, $bookings); // get the free times $time = $start; $bindex = 0; $free = array(); while ($time < $end && $bindex < count($bookings)) { if ($time < $bookings[$bindex][0]) { $free[] = [$time, $bookings[$bindex][0]]; } $time = $bookings[$bindex][1]; $bindex++; } // end of day free? if ($time < $end) { $free[] = [$time, $end]; } print_r($free);

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.3.60.0120.00616.50
8.3.50.0090.00618.15
8.3.40.0110.00420.17
8.3.30.0070.00718.84
8.3.20.0000.00820.94
8.3.10.0000.00720.16
8.3.00.0000.00720.61
8.2.180.0110.00416.50
8.2.170.0120.00622.96
8.2.160.0030.01221.15
8.2.150.0080.00024.18
8.2.140.0000.00924.66
8.2.130.0040.00426.16
8.2.120.0040.00418.67
8.2.110.0060.00321.03
8.2.100.0070.00417.78
8.2.90.0080.00018.03
8.2.80.0000.00819.25
8.2.70.0030.00617.63
8.2.60.0000.00917.63
8.2.50.0050.00317.55
8.2.40.0030.00619.42
8.2.30.0050.00319.43
8.2.20.0000.00718.18
8.2.10.0020.00519.19
8.2.00.0000.00719.29
8.1.280.0040.01125.92
8.1.270.0090.00023.83
8.1.260.0040.00426.35
8.1.250.0050.00228.09
8.1.240.0110.00019.26
8.1.230.0070.00422.27
8.1.220.0040.00417.79
8.1.210.0000.00818.77
8.1.200.0030.00617.35
8.1.190.0040.00417.35
8.1.180.0000.00818.10
8.1.170.0040.00418.76
8.1.160.0000.00818.77
8.1.150.0070.00018.95
8.1.140.0070.00018.83
8.1.130.0030.00320.14
8.1.120.0030.00617.37
8.1.110.0000.00717.45
8.1.100.0000.00817.43
8.1.90.0050.00317.48
8.1.80.0040.00417.32
8.1.70.0000.00717.47
8.1.60.0040.00417.59
8.1.50.0040.00417.52
8.1.40.0060.00317.43
8.1.30.0000.00817.64
8.1.20.0040.00417.65
8.1.10.0000.00717.51
8.1.00.0000.00717.43
8.0.300.0070.00019.89
8.0.290.0060.00316.63
8.0.280.0000.00718.44
8.0.270.0000.00717.93
8.0.260.0030.00320.08
8.0.250.0040.00416.81
8.0.240.0040.00416.92
8.0.230.0030.00316.85
8.0.220.0030.00316.89
8.0.210.0030.00316.86
8.0.200.0050.00316.96
8.0.190.0070.00016.85
8.0.180.0070.00416.84
8.0.170.0030.00616.87
8.0.160.0060.00316.94
8.0.150.0080.00016.86
8.0.140.0040.00416.86
8.0.130.0030.00313.39
8.0.120.0050.00316.90
8.0.110.0030.00316.84
8.0.100.0070.00016.92
8.0.90.0030.00616.96
8.0.80.0060.01316.90
8.0.70.0040.00416.84
8.0.60.0070.00017.01
8.0.50.0030.00516.75
8.0.30.0070.01116.98
8.0.20.0140.00316.82
8.0.10.0040.00416.91
8.0.00.0060.01216.68
7.4.330.0000.00615.55
7.4.320.0000.00616.41
7.4.300.0000.00716.59
7.4.290.0040.00416.52
7.4.280.0000.00816.60
7.4.270.0050.00216.62
7.4.260.0000.00513.24
7.4.250.0000.00716.57
7.4.240.0050.00216.47
7.4.230.0040.00416.54
7.4.220.0060.00216.46
7.4.210.0060.01016.70
7.4.200.0030.00416.68
7.4.130.0120.00516.43
7.4.120.0190.00316.57
7.4.110.0130.00416.51
7.4.100.0120.00616.45
7.4.90.0090.00916.38
7.4.80.0090.00919.39
7.4.70.0080.01216.53
7.4.60.0130.00916.53
7.4.50.0070.00216.50
7.4.40.0110.00516.44
7.4.30.0130.00316.29
7.4.20.0100.00616.30
7.4.10.0060.01616.25
7.4.00.0000.01516.47
7.3.330.0040.00416.17
7.3.320.0030.00313.12
7.3.310.0000.00616.39
7.3.300.0030.00316.28
7.3.290.0060.01116.31
7.3.260.0080.01016.44
7.3.240.0090.00816.46
7.3.230.0090.00916.74
7.3.210.0070.01116.36
7.3.200.0030.01216.52
7.3.190.0110.01016.21
7.3.180.0070.01016.49
7.3.170.0070.01616.50
7.3.160.0160.00016.49
7.3.150.0120.00916.30
7.3.140.0090.01316.41
7.3.130.0110.01116.27
7.3.120.0030.01116.35
7.3.110.0030.01416.29
7.3.100.0160.00016.46
7.3.90.0120.00316.16
7.3.80.0150.00316.38
7.3.70.0100.00716.31
7.3.60.0060.01516.36
7.3.50.0030.01216.33
7.3.40.0100.01016.33
7.3.30.0120.00616.18
7.3.20.0140.00618.13
7.3.10.0050.01518.12
7.3.00.0120.00918.06
7.2.330.0110.00716.66
7.2.320.0070.01316.38
7.2.310.0040.01916.68
7.2.300.0090.01516.76
7.2.290.0100.00716.73
7.2.280.0110.00616.70
7.2.270.0030.01316.42
7.2.260.0090.00916.71
7.2.250.0060.00916.71
7.2.240.0150.00316.47
7.2.230.0090.00916.63
7.2.220.0100.00716.47
7.2.210.0040.01116.39
7.2.200.0100.00716.55
7.2.190.0000.01516.38
7.2.180.0080.00816.54
7.2.170.0100.01016.55
7.2.160.0060.01316.55
7.2.150.0060.01418.33
7.2.140.0030.01318.42
7.2.130.0090.00618.20
7.2.120.0090.00618.38
7.2.110.0080.00818.37
7.2.100.0080.00818.30
7.2.90.0100.00618.57
7.2.80.0090.00618.34
7.2.70.0110.00618.59
7.2.60.0080.01318.39
7.2.50.0080.01318.45
7.2.40.0070.01118.21
7.2.30.0140.00318.44
7.2.20.0060.01118.34
7.2.10.0050.01118.46
7.2.00.0150.00318.36
5.5.380.0080.00515.88
5.4.00.0100.00012.27
5.3.290.0050.00512.68

preferences:
36.03 ms | 400 KiB | 5 Q