3v4l.org

run code in 300+ PHP versions simultaneously
<?php function fillDateRange($a, $b, $x = 0, $dates = []) { while (end($dates) != $b && $x = array_push($dates, date("Y-m-d", strtotime("$a +$x day")))); return $dates; } $booked = [ '2017-02-03', '2017-02-24', '2017-04-01', '2017-04-02', '2017-04-03', '2017-04-04', '2017-04-05', '2017-04-06', '2017-04-07', '2017-04-08', '2017-04-09', '2017-04-10', '2017-04-11', '2017-04-12', '2017-04-13', '2017-04-14', '2017-04-15', '2017-04-16', '2017-04-17', '2017-04-18', '2017-04-19', '2017-04-20', '2017-04-21', '2017-04-22', '2017-04-23', '2017-04-24', '2017-04-25', '2017-04-26', '2017-04-27', '2017-04-28', '2017-04-29', '2017-04-30' ]; $search = fillDateRange('2017-02-15', '2017-05-07'); // pre-validated user input // remove all dates from $search where exist in $booked... $vacant = array_diff($search, $booked); // group consecutive days $date_checker = date("Y-m-d", strtotime("{$vacant[0]} -1 day")); $x = 0; foreach ($vacant as $date) { if ($date != date("Y-m-d", strtotime("$date_checker +1 day"))) { ++$x; } $grouped[$x][] = $date; $date_checker = $date; } echo "Array of vacant date ranges:\n"; foreach ($grouped as $group) { $vacant_ranges[] = current($group) . " to " . end($group); } echo "<pre>"; var_export($vacant_ranges); echo "</pre>"; //echo "Array of arrays containing consecutive days:\n"; /*foreach ($grouped as $group) { $vacant_arrays[current($group) . " to " . end($group)] = $group; } echo "<pre>"; var_export($vacant_arrays); echo "</pre>";*/

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.5.30.0090.00919.51
8.5.20.0120.01018.77
8.5.10.0140.00717.05
8.5.00.0150.00720.21
8.4.180.0130.00925.79
8.4.170.0110.01024.02
8.4.160.0150.00823.82
8.4.150.0080.00717.02
8.4.140.0150.00917.73
8.4.130.0100.01017.88
8.4.120.0060.00320.74
8.4.110.0120.00922.19
8.4.100.0090.00618.17
8.4.90.0110.01120.66
8.4.80.0150.00519.02
8.4.70.0090.01220.54
8.4.60.0080.00220.89
8.4.50.0110.01018.95
8.4.40.0130.00317.70
8.4.30.0060.01319.02
8.4.20.0090.01217.91
8.4.10.0000.01019.68
8.3.300.0120.01020.34
8.3.290.0090.01320.61
8.3.280.0120.00818.92
8.3.270.0130.00816.91
8.3.260.0160.00516.75
8.3.250.0130.00919.09
8.3.240.0090.00816.78
8.3.230.0110.00916.66
8.3.220.0070.01118.82
8.3.210.0110.00816.84
8.3.200.0050.00416.72
8.3.190.0110.00817.40
8.3.180.0060.00219.02
8.3.170.0000.02020.69
8.3.160.0060.01317.47
8.3.150.0140.00717.33
8.3.140.0070.00718.94
8.3.130.0040.00418.64
8.3.120.0000.01020.65
8.3.110.0090.00320.94
8.3.100.0000.00924.06
8.3.90.0040.00426.77
8.3.80.0000.00917.97
8.3.70.0150.00316.88
8.3.60.0060.00918.43
8.3.50.0160.00616.80
8.3.40.0140.00321.90
8.3.30.0040.01119.16
8.3.20.0030.00524.18
8.3.10.0080.00024.66
8.3.00.0050.00326.16
8.2.300.0110.01118.83
8.2.290.0110.00818.33
8.2.280.0080.01218.66
8.2.270.0000.00817.43
8.2.260.0030.00618.87
8.2.250.0040.01118.41
8.2.240.0040.00417.46
8.2.230.0050.00522.58
8.2.220.0130.00337.54
8.2.210.0070.01426.77
8.2.200.0030.00716.88
8.2.190.0090.00916.63
8.2.180.0120.00617.13
8.2.170.0000.01419.04
8.2.160.0070.00722.96
8.2.150.0030.00525.66
8.2.140.0080.00024.66
8.2.130.0080.00026.16
8.2.120.0000.00820.84
8.2.110.0110.00022.20
8.2.100.0120.00818.83
8.2.90.0170.00618.93
8.2.80.0190.00318.89
8.2.70.0160.00819.09
8.2.60.0180.00418.86
8.2.50.0160.00618.73
8.2.40.0130.00719.11
8.2.30.0120.00918.96
8.2.20.0220.00019.04
8.2.10.0180.00219.00
8.2.00.0100.01018.74
8.1.340.0080.01219.81
8.1.330.0110.00818.59
8.1.320.0080.01218.00
8.1.310.0040.01116.95
8.1.300.0040.00418.13
8.1.290.0030.00630.84
8.1.280.0070.00725.92
8.1.270.0060.00324.66
8.1.260.0040.00426.35
8.1.250.0080.00028.09
8.1.240.0000.01122.31
8.1.230.0170.00318.94
8.1.220.0160.00318.59
8.1.210.0120.00818.52
8.1.200.0160.00318.30
8.1.190.0190.00018.66
8.1.180.0160.01318.54
8.1.170.0220.00618.48
8.1.160.0160.00818.73
8.1.150.0110.00818.36
8.1.140.0140.00518.58
8.1.130.0180.00318.51
8.1.120.0130.00618.82
8.1.110.0160.00518.70
8.1.100.0170.00318.55
8.1.90.0170.00318.80
8.1.80.0190.00018.89
8.1.70.0180.00318.73
8.1.60.0180.00419.06
8.1.50.0180.00418.78
8.1.40.0160.00518.68
8.1.30.0180.00418.71
8.1.20.0210.00018.87
8.1.10.0150.00518.61
8.1.00.0220.00018.61
8.0.300.0180.00317.86
8.0.290.0150.00518.20
8.0.280.0170.00318.01
8.0.270.0150.00517.95
8.0.260.0090.00917.99
8.0.250.0200.00018.19
8.0.240.0220.00018.04
8.0.230.0210.00318.11
8.0.220.0220.00017.97
8.0.210.0100.01018.09
8.0.200.0150.00518.13
8.0.190.0200.00018.08
8.0.180.0170.00218.17
8.0.170.0140.01418.25
8.0.160.0200.00218.07
8.0.150.0300.00617.93
8.0.140.0180.00318.10
8.0.130.0340.00818.00
8.0.120.0320.01317.94
8.0.110.0280.01618.25
8.0.100.0350.00918.07
8.0.90.0380.00618.21
8.0.80.0340.00718.09
8.0.70.0330.00717.95
8.0.60.0290.01017.96
8.0.50.0260.01017.77
8.0.30.0240.00418.07
8.0.20.0200.00418.07
8.0.10.0150.00518.44

preferences:
43.58 ms | 1136 KiB | 5 Q