3v4l.org

run code in 300+ PHP versions simultaneously
<?php // Date intervals gaps // date intervals as input (add as many as needed) $dates = array( array('01-01-2001', '31-01-2001'), array('10-02-2001', '20-02-2001'), array('31-12-2000', '30-03-2001') ); // end of input area if (!count($dates)) { echo 'No date intervals were given! <br />'; return; } $input_errors = 0; $intervals = array(); // build $intervals array with valid dates from input foreach ($dates as $i => $date) { if (!strtotime($date[0]) || !strtotime($date[1])) { $input_errors++; echo "Input error for $date[0] - $date[1] (#$i date interval). <br />"; continue; } $intervals[] = array( 'start' => date('d-m-Y', strtotime($date[0])), 'end' => date('d-m-Y', strtotime($date[1])) ); } if ($input_errors) { echo 'The given date intervals contain input error(s), as listed above, thus date gaps verification can not be performed. <br />'; echo 'For a retry, please correct the input date intervals or set a date after 1970 and before 2038. <br />'; return; } // sort $intervals array by start date of each interval $sorted = usort($intervals, "sortByStartDate"); if (!$sorted) { echo 'Error sorting intervals by start date. Exiting... <br />'; return; } print_r($sorted); // $start is the smallest start date of all intervals $start = $intervals[0]['start']; // $end is the biggest end date of all intervals $end = $intervals[0]['end']; $prev_end = $intervals[0]['end']; $total = count($intervals); $gaps = array(); if ($total == 1) { echo 'Only one date interval given, thus no gaps exist. <br />'; return; } // starting from the 2nd interval, check for gaps between $start and $end for ($j = 1; $j < $total; $j++) { if ($start > $intervals[$j]['start']) { $start = $intervals[$j]['start']; } if ((strtotime($intervals[$j]['start']) > strtotime($prev_end)) && (strtotime($end) < strtotime($intervals[$j]['start']))) { $gaps[] = array( 'start' => $prev_end, 'end' => $intervals[$j]['start'] ); } $prev_end = $intervals[$j]['end']; if ($end < $intervals[$j]['end']) { $end = $intervals[$j]['end']; } } echo "The smallest start date of all intervals is $start. <br .>"; echo "The biggest end date of all intervals is $end. <br />"; if (!count($gaps)) { echo 'The given date intervals do not contain gaps. <br />'; } else { echo 'The given date intervals contains the fallowing gaps: <br />'; foreach ($gaps as $gap) { echo '[ '. $gap['start'] . ' , ' . $gap['end'] . ' ] <br />'; } } // function used for sorting the $intervals array function sortByStartDate($a, $b) { if ($a['start'] == $b['start']) { return 0; } return ($a['start'] < $b['start']) ? -1 : 1; }

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.0100.00616.75
8.3.50.0040.01118.34
8.3.40.0140.00319.06
8.3.30.0090.00619.01
8.3.20.0070.00020.31
8.3.10.0040.00423.50
8.3.00.0040.00423.71
8.2.180.0100.01016.88
8.2.170.0060.01622.96
8.2.160.0110.00320.58
8.2.150.0000.00724.18
8.2.140.0040.00424.66
8.2.130.0050.00222.25
8.2.120.0000.00826.35
8.2.110.0030.00722.13
8.2.100.0110.00018.12
8.2.90.0060.00319.25
8.2.80.0000.00917.97
8.2.70.0090.00017.75
8.2.60.0080.00018.16
8.2.50.0040.00418.29
8.2.40.0040.00422.14
8.2.30.0040.00419.50
8.2.20.0070.00018.23
8.2.10.0030.00518.29
8.2.00.0000.00718.10
8.1.270.0060.00322.12
8.1.260.0070.00026.35
8.1.250.0050.00328.09
8.1.240.0070.01123.84
8.1.230.0090.00317.89
8.1.220.0050.00317.89
8.1.210.0080.00018.77
8.1.200.0030.00717.48
8.1.190.0050.00517.48
8.1.180.0000.00818.10
8.1.170.0040.00418.68
8.1.160.0040.00418.99
8.1.150.0030.00618.99
8.1.140.0000.00717.72
8.1.130.0040.00419.07
8.1.120.0050.00317.61
8.1.110.0070.00017.68
8.1.100.0030.00617.77
8.1.90.0040.00417.59
8.1.80.0040.00417.70
8.1.70.0070.00017.73
8.1.60.0040.00417.72
8.1.50.0000.00817.58
8.1.40.0070.00017.70
8.1.30.0040.00417.87
8.1.20.0070.00417.71
8.1.10.0080.00017.65
8.1.00.0030.00517.63
8.0.300.0040.00418.77
8.0.290.0040.00417.00
8.0.280.0070.00018.55
8.0.270.0040.00417.29
8.0.260.0070.00018.80
8.0.250.0060.00317.20
8.0.240.0040.00417.19
8.0.230.0000.00717.07
8.0.220.0030.00317.10
8.0.210.0040.00417.12
8.0.200.0030.00317.16
8.0.190.0080.00017.20
8.0.180.0000.00817.04
8.0.170.0000.00717.04
8.0.160.0040.00417.15
8.0.150.0000.00817.06
8.0.140.0030.00517.02
8.0.130.0060.00013.50
8.0.120.0000.00817.10
8.0.110.0000.00817.01
8.0.100.0000.00817.06
8.0.90.0030.00517.12
8.0.80.0070.01417.13
8.0.70.0040.00417.06
8.0.60.0000.00716.95
8.0.50.0070.00017.10
8.0.30.0140.00517.24
8.0.20.0130.00617.43
8.0.10.0030.00517.11
8.0.00.0100.01316.81
7.4.330.0050.00016.84
7.4.320.0080.00016.83
7.4.300.0000.00716.68
7.4.290.0090.00316.57
7.4.280.0000.00916.59
7.4.270.0070.00016.75
7.4.260.0050.00316.69
7.4.250.0040.00416.69
7.4.240.0040.00416.77
7.4.230.0000.00716.88
7.4.220.0070.01116.70
7.4.210.0100.00716.75
7.4.200.0050.00216.75
7.4.160.0080.01016.82
7.4.150.0060.01217.40
7.4.140.0110.00617.86
7.4.130.0090.00916.58
7.4.120.0100.01016.69
7.4.110.0050.01816.59
7.4.100.0150.00316.66
7.4.90.0060.01316.68
7.4.80.0060.01119.39
7.4.70.0070.01016.75
7.4.60.0070.01116.86
7.4.50.0040.01416.55
7.4.40.0140.00316.66
7.4.30.0110.00816.70
7.4.00.0000.01315.37
7.3.330.0030.00313.49
7.3.320.0030.00313.55
7.3.310.0030.00516.42
7.3.300.0070.00016.40
7.3.290.0050.01116.54
7.3.280.0090.00916.51
7.3.270.0160.00317.40
7.3.260.0130.00516.73
7.3.250.0100.00916.80
7.3.240.0120.00716.63
7.3.230.0130.01016.64
7.3.210.0110.00716.80
7.3.200.0080.00816.78
7.3.190.0130.00716.60
7.3.180.0130.00316.78
7.3.170.0110.00516.57
7.3.160.0030.01216.60
7.3.10.0090.00416.71
7.3.00.0050.00916.70
7.2.330.0070.01716.67
7.2.320.0030.01516.69
7.2.310.0140.00316.99
7.2.300.0070.01016.93
7.2.290.0160.00416.84
7.2.130.0080.00917.22
7.2.120.0060.01017.06
7.2.110.0090.01016.79
7.2.100.0050.01016.79
7.2.90.0120.00517.09
7.2.80.0080.00816.85
7.2.70.0080.00317.14
7.2.60.0180.00316.99
7.2.50.0080.00417.03
7.2.40.0040.00816.92
7.2.30.0060.01017.12
7.2.20.0130.00517.01
7.2.10.0060.00617.00
7.2.00.0080.00317.13
7.1.250.0080.00515.94
7.1.200.0130.00016.18
7.1.110.0360.00916.32
7.1.100.0530.01616.54
7.1.90.0740.00316.04
7.1.80.0570.00616.38
7.1.70.0490.00915.42
7.1.60.1020.01433.51
7.1.50.1010.02532.99
7.1.40.0900.01332.85
7.1.30.1370.01533.05
7.1.20.0810.01332.99
7.1.10.0490.01614.90
7.1.00.0570.00814.99
7.0.250.0630.00716.15
7.0.240.0550.01016.14
7.0.230.0600.00716.17
7.0.220.0790.01015.79
7.0.210.0550.01014.91
7.0.200.0910.00615.22
7.0.190.0870.00714.99
7.0.180.0910.01014.58
7.0.170.1100.00314.75
7.0.160.0770.01014.68
7.0.150.0710.00714.55
7.0.140.0580.01414.62
7.0.130.0760.01614.79
7.0.120.0650.01415.03
7.0.110.0530.01014.73
7.0.100.0510.01314.75
7.0.90.0400.01714.87
7.0.80.0560.00314.75
7.0.70.0470.01114.71
7.0.60.0480.01414.66
7.0.50.0470.01614.66
7.0.40.0610.00714.83
7.0.30.0420.01014.77
7.0.20.0470.01014.65
7.0.10.0480.01914.80
7.0.00.0570.00714.66

preferences:
67.54 ms | 400 KiB | 5 Q