3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getOverlapDays($ranges) { $overlapDays = 0; // no overlap by default $range = $ranges[0]; // starting with the first element of range array $itemsCnt = count($ranges); for ($id = 1; $id < $itemsCnt; $id++) { $start1 = is_a($range["start"], "DateTime") ? $range["start"] : new DateTime($range["start"]); $end1 = is_a($range["end"], "DateTime") ? $range["end"] : new DateTime($range["end"]); $start2 = is_a($ranges[$id]["start"], "DateTime") ? $ranges[$id]["start"] : new DateTime($ranges[$id]["start"]); $end2 = is_a($ranges[$id]["end"], "DateTime") ? $ranges[$id]["end"] : new DateTime($ranges[$id]["end"]); if ($start1 <= $end2 && $end1 >= $start2) { // if the dates overlap return min($end1, $end2)->diff(max($start2, $start1))->days + 1; // return how many days overlap } else { $range = [ "start" => $start1 > $start2 ? $start1 : $start2, "end" => $end1 > $end2 ? $end1 : $end2 ]; } } return $overlapDays; } // example $ranges = array( array('start' => '2013-12-15', 'end' => '2013-12-31'), array('start' => '2014-01-01', 'end' => '2014-01-31'), array('start' => '2014-01-01', 'end' => '2014-01-10') ); echo getOverlapDays($ranges);

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.0070.00716.75
8.3.50.0070.01122.99
8.3.40.0100.00719.10
8.3.30.0100.00719.35
8.3.20.0070.00020.04
8.3.10.0070.00721.59
8.3.00.0040.00419.69
8.2.180.0060.01216.75
8.2.170.0130.00722.96
8.2.160.0140.00020.87
8.2.150.0050.00324.18
8.2.140.0000.00824.66
8.2.130.0070.00026.16
8.2.120.0080.00021.03
8.2.110.0030.00622.20
8.2.100.0040.00719.28
8.2.90.0040.00419.34
8.2.80.0000.00819.40
8.2.70.0090.00017.75
8.2.60.0090.00018.05
8.2.50.0030.00618.07
8.2.40.0030.00618.34
8.2.30.0040.00418.21
8.2.20.0000.00818.00
8.2.10.0040.00418.21
8.2.00.0000.00918.01
8.1.280.0090.00625.92
8.1.270.0090.00022.13
8.1.260.0040.00426.35
8.1.250.0000.00728.09
8.1.240.0030.00623.72
8.1.230.0110.00019.10
8.1.220.0040.00417.79
8.1.210.0090.00018.77
8.1.200.0060.00317.48
8.1.190.0030.00517.52
8.1.180.0040.00420.29
8.1.170.0050.00318.77
8.1.160.0080.00022.20
8.1.150.0040.00418.82
8.1.140.0070.00017.70
8.1.130.0070.00017.84
8.1.120.0000.00717.58
8.1.110.0000.00717.57
8.1.100.0070.00017.67
8.1.90.0000.00917.70
8.1.80.0050.00317.75
8.1.70.0070.00017.57
8.1.60.0080.00017.75
8.1.50.0050.00317.57
8.1.40.0060.00617.70
8.1.30.0080.00017.70
8.1.20.0000.00817.66
8.1.10.0040.00417.80
8.1.00.0000.00717.75
8.0.300.0000.00718.77
8.0.290.0000.00817.18
8.0.280.0000.00718.54
8.0.270.0040.00417.26
8.0.260.0030.00317.31
8.0.250.0040.00417.19
8.0.240.0000.00717.14
8.0.230.0030.00317.21
8.0.220.0030.00317.02
8.0.210.0060.00317.07
8.0.200.0030.00317.13
8.0.190.0040.00417.14
8.0.180.0040.00417.16
8.0.170.0060.00317.04
8.0.160.0080.00017.11
8.0.150.0030.00617.11
8.0.140.0070.00017.05
8.0.130.0000.00613.43
8.0.120.0040.00417.05
8.0.110.0030.00617.07
8.0.100.0080.00017.09
8.0.90.0030.00516.97
8.0.80.0060.01017.06
8.0.70.0000.00816.93
8.0.60.0050.00317.23
8.0.50.0040.00416.93
8.0.30.0090.00917.12
8.0.20.0110.00817.40
8.0.10.0050.00217.27
8.0.00.0060.01116.92
7.4.330.0030.00315.09
7.4.320.0030.00316.74
7.4.300.0060.00016.76
7.4.290.0030.00816.76
7.4.280.0040.00416.57
7.4.270.0000.00816.55
7.4.260.0080.00016.71
7.4.250.0040.00416.52
7.4.240.0020.00516.56
7.4.230.0030.00316.58
7.4.220.0100.00916.76
7.4.210.0080.00616.84
7.4.200.0070.00016.54
7.4.160.0040.01216.53
7.4.150.0140.00317.40
7.4.140.0140.00817.86
7.4.130.0100.00716.66
7.4.120.0110.00516.83
7.4.110.0060.01216.77
7.4.100.0100.00716.60
7.4.90.0060.01216.73
7.4.80.0120.00919.39
7.4.70.0040.01816.71
7.4.60.0050.01216.64
7.4.50.0040.00416.81
7.4.40.0110.00616.93
7.4.30.0130.01016.80
7.4.00.0060.00915.04
7.3.330.0050.00013.37
7.3.320.0060.00013.47
7.3.310.0070.00016.51
7.3.300.0030.00316.51
7.3.290.0080.00716.51
7.3.280.0110.00816.49
7.3.270.0120.00617.40
7.3.260.0070.01016.73
7.3.250.0120.00516.78
7.3.240.0100.00716.68
7.3.230.0080.01216.76
7.3.210.0030.01316.68
7.3.200.0130.00719.39
7.3.190.0030.01716.64
7.3.180.0120.00316.58
7.3.170.0120.00916.47
7.3.160.0130.00316.52
7.2.330.0140.00317.03
7.2.320.0040.01516.89
7.2.310.0140.01016.61
7.2.300.0100.01016.98
7.2.290.0040.01816.84
7.1.70.0030.00717.11
7.1.60.0090.01219.34
7.1.50.0060.01517.11
7.1.00.0070.07322.37
7.0.200.0000.00816.98
7.0.140.0030.06721.99
7.0.60.0070.08720.02
7.0.50.0030.06317.90
7.0.40.0070.04020.27
7.0.30.0630.06320.10
7.0.20.0370.06720.24
7.0.10.0070.09020.24
7.0.00.0130.06320.22
5.6.280.0030.07321.13
5.6.210.0170.03320.64
5.6.200.0070.08318.23
5.6.190.0000.09020.48
5.6.180.0070.04720.52
5.6.170.0200.06020.48
5.6.160.0070.08720.39
5.6.150.0130.07318.19
5.6.140.0070.04018.24
5.6.130.0030.07718.18
5.6.120.0070.04321.00
5.6.110.0000.04320.98
5.6.100.0030.09021.20
5.6.90.0000.04320.99
5.6.80.0100.07720.40
5.6.70.4430.04320.29
5.5.350.0000.08020.45
5.5.340.0100.08018.05
5.5.330.0100.08320.37
5.5.320.0230.07720.35
5.5.310.0200.04320.27
5.5.300.0070.07017.97
5.5.290.0070.06717.93
5.5.280.0130.07020.78
5.5.270.0100.08320.90
5.5.260.0170.07320.80
5.5.250.0070.08020.79
5.5.240.0270.08320.08
5.4.450.0270.05319.60
5.4.440.1500.06319.71
5.4.430.1470.04719.30
5.4.420.0830.06019.55
5.4.410.0830.05719.18
5.4.400.1430.05019.15
5.4.390.1370.05719.28
5.4.380.0130.06018.80
5.4.370.0100.06018.54
5.4.360.0200.05018.77
5.4.350.0170.05013.80
5.4.340.0370.05713.77
5.4.320.0230.04714.25
5.4.310.0200.05314.28
5.4.300.0200.05714.34
5.4.290.0170.04714.28
5.4.280.0130.04014.32
5.4.270.0370.04014.24
5.4.260.0130.05314.40
5.4.250.0200.05014.23
5.4.240.0170.05014.16
5.4.230.0130.06014.23
5.4.220.0130.05714.17
5.4.210.0370.04014.11
5.4.200.0330.04314.17
5.4.190.0230.04714.16
5.4.180.0130.05714.16
5.4.170.0100.05714.16
5.4.160.0170.04014.17
5.4.150.0230.03714.11
5.4.140.0300.03713.87
5.4.130.0170.05713.78
5.4.120.0070.04713.81
5.4.110.0100.04313.78
5.4.100.0070.04013.76
5.4.90.0070.04313.94
5.4.80.0100.05713.85
5.4.70.0100.05713.79
5.4.60.0100.04013.79
5.4.50.0130.04714.02
5.4.40.0100.05713.80
5.4.30.0200.04313.75
5.4.20.0270.04013.79
5.4.10.0400.07713.76
5.4.00.0130.05013.26
5.3.290.0170.07314.72
5.3.280.0200.04714.58
5.3.270.0230.04714.61
5.3.260.0170.05014.76
5.3.250.0130.05014.60
5.3.240.0130.06314.54
5.3.230.0100.03714.55
5.3.220.0030.04314.62
5.3.210.0200.04014.64
5.3.200.0100.03714.77
5.3.190.0070.04014.52
5.3.180.0070.04014.57
5.3.170.0070.06314.76
5.3.160.0100.04314.60
5.3.150.0130.04714.75
5.3.140.0030.04014.70
5.3.130.0130.04014.72
5.3.120.0230.03314.54
5.3.110.0230.04314.63
5.3.100.0070.05714.09
5.3.90.0170.04714.02
5.3.80.0270.04313.99
5.3.70.0230.04313.98
5.3.60.0100.05013.97
5.3.50.0430.05014.00
5.3.40.0100.05013.95
5.3.30.0170.03013.89
5.3.20.0100.04013.77
5.3.10.0200.03313.79
5.3.00.0030.04313.64
5.2.170.0170.02711.09
5.2.160.0070.03711.18
5.2.150.0170.03011.11
5.2.140.0170.03011.13
5.2.130.0070.03311.23
5.2.120.0100.03011.14
5.2.110.0200.02311.16
5.2.100.0130.03711.16
5.2.90.0200.03011.27
5.2.80.0330.03311.07
5.2.70.0130.04311.11
5.2.60.0170.04010.98
5.2.50.0130.03710.97
5.2.40.0130.04011.09
5.2.30.0070.04311.14
5.2.20.0100.03711.11
5.2.10.0230.06011.03
5.2.00.0100.03310.66
5.1.60.0100.02710.01
5.1.50.0100.03710.07
5.1.40.0100.0379.97
5.1.30.0130.03710.41
5.1.20.0030.04310.50
5.1.10.0100.03710.09
5.1.00.0170.03010.13
5.0.50.0070.0338.71
5.0.40.0030.0278.49
5.0.30.0070.0408.21
5.0.20.0230.0208.19
5.0.10.0030.0238.13
5.0.00.0100.0338.16
4.4.90.0000.0235.88
4.4.80.0070.0135.98
4.4.70.0030.0175.83
4.4.60.0000.0206.01
4.4.50.0030.0175.88
4.4.40.0030.0275.86
4.4.30.0070.0135.92
4.4.20.0070.0135.88
4.4.10.0030.0176.03
4.4.00.0030.0275.89
4.3.110.0030.0175.86
4.3.100.0030.0205.81
4.3.90.0030.0175.83
4.3.80.0070.0235.77
4.3.70.0000.0175.76
4.3.60.0000.0205.92
4.3.50.0070.0135.78
4.3.40.0070.0235.75
4.3.30.0030.0174.59
4.3.20.0000.0204.50
4.3.10.0000.0204.48
4.3.00.0070.01714.42

preferences:
48.48 ms | 401 KiB | 5 Q