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-31', 'end' => '2014-01-01'), array('start' => '2014-01-01', 'end' => '2014-01-31') ); 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.40.0060.01218.88
8.3.30.0100.00719.20
8.3.20.0000.00820.21
8.3.10.0040.00421.65
8.3.00.0060.00318.03
8.2.170.0140.00722.96
8.2.160.0070.00720.53
8.2.150.0040.00424.18
8.2.140.0040.00424.66
8.2.130.0000.00926.16
8.2.120.0080.00020.78
8.2.110.0060.00321.03
8.2.100.0000.01118.16
8.2.90.0040.00419.34
8.2.80.0050.00317.97
8.2.70.0000.00817.88
8.2.60.0050.00317.93
8.2.50.0000.00818.07
8.2.40.0080.00018.34
8.2.30.0060.00318.31
8.2.20.0040.00418.07
8.2.10.0040.00418.17
8.2.00.0000.00718.01
8.1.270.0080.00023.99
8.1.260.0100.00726.35
8.1.250.0080.00028.09
8.1.240.0030.00621.44
8.1.230.0040.00717.63
8.1.220.0050.00317.79
8.1.210.0090.00018.77
8.1.200.0030.00717.48
8.1.190.0030.00517.47
8.1.180.0040.00420.07
8.1.170.0030.00618.73
8.1.160.0050.00222.17
8.1.150.0000.00718.98
8.1.140.0000.00717.66
8.1.130.0070.00017.92
8.1.120.0040.00417.64
8.1.110.0000.00717.73
8.1.100.0040.00417.65
8.1.90.0000.00717.56
8.1.80.0050.00317.57
8.1.70.0030.00317.63
8.1.60.0050.00317.73
8.1.50.0000.00817.60
8.1.40.0060.00317.67
8.1.30.0000.00817.84
8.1.20.0000.00817.81
8.1.10.0040.00417.80
8.1.00.0060.00617.77
8.0.300.0040.00418.77
8.0.290.0030.00617.00
8.0.280.0030.00318.53
8.0.270.0000.00717.02
8.0.260.0030.00317.41
8.0.250.0000.00717.11
8.0.240.0040.00417.19
8.0.230.0070.00017.23
8.0.220.0000.00717.14
8.0.210.0000.00717.04
8.0.200.0050.00217.16
8.0.190.0040.00417.07
8.0.180.0000.00717.09
8.0.170.0000.00817.03
8.0.160.0040.00417.11
8.0.150.0070.00017.12
8.0.140.0070.00017.04
8.0.130.0030.00313.50
8.0.120.0000.00817.19
8.0.110.0030.00616.95
8.0.100.0070.00016.93
8.0.90.0000.00717.09
8.0.80.0030.01317.06
8.0.70.0040.00417.11
8.0.60.0030.00517.08
8.0.50.0040.00417.12
8.0.30.0110.00817.37
8.0.20.0140.00817.41
8.0.10.0000.00717.20
8.0.00.0100.00716.96
7.4.330.0050.00015.22
7.4.320.0000.00616.66
7.4.300.0050.00216.72
7.4.290.0060.00316.73
7.4.280.0070.00016.71
7.4.270.0070.00016.77
7.4.260.0000.00716.74
7.4.250.0030.00616.66
7.4.240.0040.00316.67
7.4.230.0040.00416.78
7.4.220.0120.00616.59
7.4.210.0040.01116.70
7.4.200.0000.00716.64
7.4.160.0160.00016.68
7.4.150.0190.00317.40
7.4.140.0140.00617.86
7.4.130.0110.00816.72
7.4.120.0060.01216.85
7.4.110.0070.01316.62
7.4.100.0120.00916.64
7.4.90.0030.01316.66
7.4.80.0140.00319.39
7.4.70.0080.01016.68
7.4.60.0110.00616.64
7.4.50.0040.00016.62
7.4.40.0070.01016.71
7.4.30.0100.00716.83
7.4.00.0070.01115.00
7.3.330.0000.00513.51
7.3.320.0000.00513.34
7.3.310.0000.00716.51
7.3.300.0030.00316.59
7.3.290.0070.00816.50
7.3.280.0070.00916.54
7.3.270.0120.00617.40
7.3.260.0130.00616.74
7.3.250.0080.01016.59
7.3.240.0030.01416.67
7.3.230.0080.00816.75
7.3.210.0170.00016.62
7.3.200.0160.00719.39
7.3.190.0140.01516.75
7.3.180.0120.00316.74
7.3.170.0130.00316.77
7.3.160.0100.00616.67
7.3.120.0130.00315.02
7.3.110.0100.01015.16
7.3.100.0090.00615.27
7.3.90.0030.01015.12
7.3.80.0110.00414.96
7.3.70.0000.01014.90
7.3.60.0060.00614.70
7.3.50.0000.01314.80
7.3.40.0110.00714.98
7.3.30.0040.01115.04
7.3.20.0030.01016.93
7.3.10.0050.00517.01
7.3.00.0040.00816.98
7.2.330.0130.00616.99
7.2.320.0070.01116.69
7.2.310.0130.00316.98
7.2.300.0120.00817.00
7.2.290.0030.01316.73
7.2.250.0110.00815.27
7.2.240.0070.01415.13
7.2.230.0040.01115.31
7.2.220.0030.01015.04
7.2.210.0040.00815.18
7.2.200.0070.01015.31
7.2.190.0030.00614.91
7.2.180.0000.00915.34
7.2.170.0070.00315.16
7.2.00.0030.01119.39
7.1.330.0030.01015.80
7.1.320.0040.00816.22
7.1.310.0030.00715.97
7.1.300.0040.00415.75
7.1.290.0040.00716.10
7.1.280.0030.01015.77
7.1.270.0000.00815.71
7.1.260.0040.00816.03
7.1.100.0090.00318.48
7.1.70.0070.01017.34
7.1.60.0040.01117.39
7.1.50.0040.01917.08
7.1.00.0030.07722.57
7.0.200.0000.01016.88
7.0.140.0030.03322.15
7.0.60.0100.08319.95
7.0.50.0130.06317.91
7.0.40.0000.06720.05
7.0.30.0170.05720.30
7.0.20.0400.07720.06
7.0.10.0130.07320.19
7.0.00.0000.04720.30
5.6.280.0070.07021.00
5.6.210.0100.03720.77
5.6.200.0070.06018.19
5.6.190.0000.04720.77
5.6.180.0000.05320.47
5.6.170.0230.04320.40
5.6.160.0130.08020.44
5.6.150.0000.08018.29
5.6.140.0000.04318.17
5.6.130.0030.05318.19
5.6.120.0170.07321.03
5.6.110.0130.07721.04
5.6.100.0100.03721.14
5.6.90.0030.09020.89
5.6.80.0030.08320.39
5.5.350.4170.04320.47
5.5.340.0170.06318.08
5.5.330.0100.04720.56
5.5.320.0270.03320.38
5.5.310.0230.07020.30
5.5.300.0030.04717.98
5.5.290.0070.06717.99
5.5.280.0070.09020.63
5.5.270.0170.06720.96
5.5.260.0100.08720.77
5.5.250.0030.08320.70
5.5.240.0130.06720.28
5.4.450.0330.06319.48
5.4.440.0900.08719.59
5.4.430.0200.04319.31
5.4.420.0070.06019.45
5.4.410.0130.05019.41
5.4.400.0070.06019.25
5.4.390.0070.05319.05
5.4.380.0230.05018.81
5.4.370.0130.05718.59
5.4.360.0200.04718.86
5.4.350.0100.03713.95
5.4.340.0070.03713.80
5.4.320.0100.05014.34
5.4.310.0030.04314.50
5.4.300.0130.04014.35
5.4.290.0130.03314.25
5.4.280.0030.03714.41
5.4.270.0070.03714.29
5.4.260.0100.03314.16
5.4.250.0070.03714.18
5.4.240.0070.04014.12
5.4.230.0130.03314.20
5.4.220.0100.03714.15
5.4.210.0070.04014.11
5.4.200.0000.04714.28
5.4.190.0130.03014.31
5.4.180.0130.03014.14
5.4.170.0070.04014.19
5.4.160.0100.03314.32
5.4.150.0070.03714.39
5.4.140.0100.03713.85
5.4.130.0000.04313.95
5.4.120.0070.03713.85
5.4.110.0130.03013.79
5.4.100.0070.03713.90
5.4.90.0070.04013.89
5.4.80.0070.04313.79
5.4.70.0030.04013.86
5.4.60.0070.03313.94
5.4.50.0100.03313.76
5.4.40.0170.04313.76
5.4.30.0070.04313.84
5.4.20.0030.05013.75
5.4.10.0130.04313.70
5.4.00.0070.05013.28
5.3.290.0130.03714.60
5.3.280.0200.04314.60
5.3.270.0070.05014.63
5.3.260.0200.04314.56
5.3.250.0070.05014.65
5.3.240.0030.04314.63
5.3.230.0070.04714.66
5.3.220.0130.03714.68
5.3.210.0170.03314.68
5.3.200.0100.04014.68
5.3.190.0070.04014.61
5.3.180.0030.04014.74
5.3.170.0070.04014.73
5.3.160.0100.04714.54
5.3.150.0030.04314.71
5.3.140.0100.05014.50
5.3.130.0170.04714.48
5.3.120.0070.04314.58
5.3.110.0070.04714.66
5.3.100.0070.04014.06
5.3.90.0200.02714.20
5.3.80.0070.03713.95
5.3.70.0100.04014.02
5.3.60.0130.04013.96
5.3.50.0130.03014.11
5.3.40.0030.04014.10
5.3.30.0030.04013.91
5.3.20.0070.03713.70
5.3.10.0100.03313.80
5.3.00.0100.03313.59
5.2.170.0130.03011.31
5.2.160.0100.03011.17
5.2.150.0070.04011.25
5.2.140.0100.03711.12
5.2.130.0100.02711.07
5.2.120.0030.03311.05
5.2.110.0030.03311.13
5.2.100.0030.03011.11
5.2.90.0000.03711.26
5.2.80.0030.04011.15
5.2.70.0070.02711.10
5.2.60.0100.02711.10
5.2.50.0030.03010.98
5.2.40.0070.03011.02
5.2.30.0000.03311.00
5.2.20.0030.03011.10
5.2.10.0100.02311.01
5.2.00.0100.02710.73
5.1.60.0030.02710.05
5.1.50.0030.0309.95
5.1.40.0100.02010.02
5.1.30.0030.03010.27
5.1.20.0030.03310.39
5.1.10.0000.03710.04
5.1.00.0030.03710.05
5.0.50.0000.0278.53
5.0.40.0030.0208.40
5.0.30.0070.0308.38
5.0.20.0000.0278.31
5.0.10.0000.0278.12
5.0.00.0000.0338.23
4.4.90.0000.0206.03
4.4.80.0030.0175.85
4.4.70.0070.0135.88
4.4.60.0100.0135.93
4.4.50.0070.0205.87
4.4.40.0000.0375.91
4.4.30.0070.0175.97
4.4.20.0030.0235.99
4.4.10.0100.0135.98
4.4.00.0030.0276.00
4.3.110.0070.0135.82
4.3.100.0030.0135.78
4.3.90.0030.0135.84
4.3.80.0000.0275.76
4.3.70.0030.0135.79
4.3.60.0030.0135.88
4.3.50.0030.0135.77
4.3.40.0070.0205.80
4.3.30.0070.0134.51
4.3.20.0030.0174.57
4.3.10.0000.0204.54
4.3.00.0070.0207.01

preferences:
47.43 ms | 400 KiB | 5 Q