3v4l.org

run code in 300+ PHP versions simultaneously
<?php /* This is the result i want from $uptime, all periods where there are no incidents between period_start and period_end. -------------------------------------------------- Array ( [0] => Array ( [start] => 2016-01-01 00:00:00 [end] => 2016-01-05 00:00:00 ) [1] => Array ( [start] => 2016-01-15 22:00:00 [end] => 2016-01-20 00:00:00 ) [2] => Array ( [start] => 2016-01-25 23:59:59 [end] => 2016-01-31 23:59:59 ) ) -------------------------------------------------- */ $period_start = '2016-01-01 00:00:00'; $period_end = '2016-01-31 23:59:59'; $uptime = []; $incidents = [ ['start' => '2016-01-05 00:00:00', 'end' => '2016-01-10 23:59:59'], ['start' => '2016-01-07 00:00:00', 'end' => '2016-01-15 22:00:00'], // overlapping ['start' => '2016-01-08 00:00:00', 'end' => '2016-01-12 23:59:59'], // overlapping ['start' => '2016-01-20 00:00:00', 'end' => '2016-01-25 23:59:59'], ['start' => '2016-01-23 00:00:00', 'end' => '2016-01-24 23:59:59'] // overlapping ]; // First period if(strtotime($period_start) <= strtotime($incidents[0]['start'])) { array_push($uptime, ['start' => $period_start, 'end' => $incidents[0]['start']]); } $last_end = 0; // Used for finding the last ending incident. for($i = 0;$i < sizeof($incidents);$i++) { $push = true; $last_end_j = $incidents[$i]['end']; for($j = $i+1;$j < sizeof($incidents);$j++) { if(strtotime($incidents[$j]['end']) > strtotime($last_end_j)) { $last_end_j = $incidents[$j]['end']; } if(strtotime($incidents[$i]['end']) < strtotime($incidents[$j]['start'])) { if($push) { array_push($uptime, ['start' => $last_end_j, 'end' => $incidents[$j]['start']]); } break; } else { $push = false; } } // Saving for last period if(strtotime($incidents[$i]['end']) > strtotime($last_end)) { $last_end = $incidents[$i]['end']; } } // Last period if(strtotime($period_end) >= strtotime($last_end)) { array_push($uptime, ['start' => $last_end, 'end' => $period_end]); } print_r( $uptime );

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.0040.01116.75
8.3.50.0130.00321.24
8.3.40.0120.00318.95
8.3.30.0130.00318.92
8.3.20.0040.00418.85
8.3.10.0000.00821.60
8.3.00.0000.00821.90
8.2.180.0110.00416.63
8.2.170.0040.01122.96
8.2.160.0030.01022.27
8.2.150.0040.00424.18
8.2.140.0030.00624.66
8.2.130.0050.00319.89
8.2.120.0040.00426.35
8.2.110.0070.00321.06
8.2.100.0080.00417.97
8.2.90.0030.00618.16
8.2.80.0000.00817.97
8.2.70.0030.00517.90
8.2.60.0000.00818.05
8.2.50.0050.00318.22
8.2.40.0040.00420.55
8.2.30.0040.00419.48
8.2.20.0000.00718.22
8.2.10.0000.00718.07
8.2.00.0030.00617.82
8.1.280.0120.00325.92
8.1.270.0080.00023.91
8.1.260.0080.00028.09
8.1.250.0080.00028.09
8.1.240.0100.00021.11
8.1.230.0040.00819.10
8.1.220.0030.00517.79
8.1.210.0050.00318.77
8.1.200.0060.00317.48
8.1.190.0050.00317.50
8.1.180.0030.00518.10
8.1.170.0000.00818.71
8.1.160.0000.00823.91
8.1.150.0020.00520.65
8.1.140.0000.00719.61
8.1.130.0060.00317.73
8.1.120.0000.00817.53
8.1.110.0030.00517.64
8.1.100.0040.00417.66
8.1.90.0050.00317.70
8.1.80.0000.00817.70
8.1.70.0000.00717.64
8.1.60.0030.00617.72
8.1.50.0040.00417.57
8.1.40.0030.00517.64
8.1.30.0030.00617.78
8.1.20.0040.00417.78
8.1.10.0000.00817.74
8.1.00.0080.00317.69
8.0.300.0080.00021.75
8.0.290.0040.00417.00
8.0.280.0030.00318.60
8.0.270.0040.00417.41
8.0.260.0030.00317.37
8.0.250.0030.00317.19
8.0.240.0030.00317.19
8.0.230.0070.00017.07
8.0.220.0070.00017.06
8.0.210.0040.00417.19
8.0.200.0000.00617.18
8.0.190.0030.00517.17
8.0.180.0000.00717.15
8.0.170.0030.00517.19
8.0.160.0080.00017.21
8.0.150.0000.00717.05
8.0.140.0040.00417.13
8.0.130.0000.00513.44
8.0.120.0060.00317.13
8.0.110.0070.00016.98
8.0.100.0050.00317.00
8.0.90.0040.00417.10
8.0.80.0130.00317.05
8.0.70.0040.00417.18
8.0.60.0000.00717.20
8.0.50.0040.00416.93
8.0.30.0090.00817.16
8.0.20.0130.01417.46
8.0.10.0070.00017.33
8.0.00.0120.00616.78
7.4.330.0050.00015.55
7.4.320.0030.00516.58
7.4.300.0000.00616.68
7.4.290.0000.00716.71
7.4.280.0080.00016.64
7.4.270.0000.00716.69
7.4.260.0060.00316.80
7.4.250.0050.00216.63
7.4.240.0000.00716.83
7.4.230.0030.00316.58
7.4.220.0070.01716.84
7.4.210.0030.01616.64
7.4.200.0070.00016.81
7.4.160.0090.00716.69
7.4.150.0120.00617.40
7.4.140.0100.00717.86
7.4.130.0060.01216.78
7.4.120.0090.00916.63
7.4.110.0060.01316.61
7.4.100.0120.01216.81
7.4.90.0070.01116.66
7.4.80.0000.01719.39
7.4.70.0090.00816.61
7.4.60.0140.00816.61
7.4.50.0070.01016.65
7.4.40.0090.00916.66
7.4.30.0040.01516.65
7.4.00.0070.01215.18
7.3.330.0000.00613.23
7.3.320.0050.00013.32
7.3.310.0030.00316.57
7.3.300.0030.00316.39
7.3.290.0100.00716.52
7.3.280.0070.01116.50
7.3.270.0090.00917.40
7.3.260.0080.01016.72
7.3.250.0100.00816.61
7.3.240.0080.01116.68
7.3.230.0030.01416.56
7.3.210.0130.00316.90
7.3.200.0130.00316.82
7.3.190.0090.00916.71
7.3.180.0030.01316.57
7.3.170.0070.01016.55
7.3.160.0140.00316.68
7.3.120.0070.01115.14
7.3.110.0140.00415.19
7.3.100.0070.00715.04
7.3.90.0090.00615.16
7.3.80.0090.00614.68
7.3.70.0090.00614.98
7.3.60.0060.00914.75
7.3.50.0030.01014.93
7.3.40.0030.00915.00
7.3.30.0060.00314.91
7.3.20.0090.00616.96
7.3.10.0000.00917.05
7.3.00.0050.00716.79
7.2.330.0120.00616.55
7.2.320.0070.01016.71
7.2.310.0140.00716.66
7.2.300.0070.01716.73
7.2.290.0120.00616.94
7.2.250.0090.00915.18
7.2.240.0100.01015.32
7.2.230.0030.01315.16
7.2.220.0060.00315.56
7.2.210.0070.00715.24
7.2.200.0080.00415.25
7.2.190.0040.01115.19
7.2.180.0000.01415.39
7.2.170.0000.01215.16
7.2.130.0060.00917.13
7.2.120.0070.00716.85
7.2.110.0030.01016.86
7.2.100.0040.01016.80
7.2.90.0060.00617.06
7.2.80.0090.00917.06
7.2.70.0070.00716.66
7.2.60.0050.00617.09
7.2.50.0100.00317.08
7.2.40.0040.00717.11
7.2.30.0120.00317.00
7.2.20.0030.01317.17
7.2.10.0070.00717.07
7.2.00.0080.00818.27
7.1.330.0080.00816.10
7.1.320.0080.00416.04
7.1.310.0000.01316.04
7.1.300.0030.01216.00
7.1.290.0070.00715.83
7.1.280.0060.00916.11
7.1.270.0040.00715.62
7.1.260.0040.00815.58
7.1.250.0150.00315.73
7.1.240.0030.00616.04
7.1.230.0000.01415.65
7.1.220.0090.00615.64
7.1.210.0070.00715.95
7.1.200.0090.00515.78
7.1.190.0030.01216.00
7.1.180.0040.00816.00
7.1.170.0000.01316.04
7.1.160.0000.01016.09
7.1.150.0080.00416.00
7.1.140.0030.01315.71
7.1.130.0100.00715.89
7.1.120.0100.00315.81
7.1.110.0030.01016.04
7.1.100.0040.01116.01
7.1.90.0070.00316.07
7.1.80.0040.01116.06
7.1.70.0080.00216.57
7.1.60.0080.00316.61
7.1.50.0050.00816.61
7.1.40.0060.00716.43
7.1.30.0070.00616.40
7.1.20.0080.00316.30
7.1.10.0080.00716.29
7.1.00.0040.00516.33
7.0.330.0030.01215.43
7.0.320.0000.01115.50
7.0.310.0030.01315.31
7.0.300.0030.00615.57
7.0.290.0070.00515.62
7.0.280.0090.00615.38
7.0.270.0040.01215.24
7.0.260.0030.01015.43
7.0.250.0120.00615.54
7.0.240.0100.00315.42
7.0.230.0070.00715.45
7.0.220.0000.01515.70
7.0.210.0060.00915.59
7.0.200.0070.00416.27
7.0.190.0030.00716.25
7.0.180.0090.00016.25
7.0.170.0040.00716.12
7.0.160.0070.00416.05
7.0.150.0050.00516.14
7.0.140.0000.01116.23
7.0.130.0060.00716.25
7.0.120.0060.00716.18
7.0.110.0010.01016.00
7.0.100.0070.00816.08
7.0.90.0050.01016.19
7.0.80.0040.00616.02
7.0.70.0010.01016.14
7.0.60.0070.00816.23
7.0.50.0060.00316.34
7.0.40.0010.00815.23
7.0.30.0050.01015.10
7.0.20.0060.00615.21
7.0.10.0060.00615.23
7.0.00.0040.00915.30
5.6.380.0100.00314.68
5.6.370.0040.01214.48
5.6.360.0040.00814.34
5.6.350.0110.00314.47
5.6.340.0030.00913.80
5.6.330.0100.00314.33
5.6.320.0110.00514.50
5.6.310.0070.00714.53
5.6.300.0080.02017.64
5.6.290.0070.02217.78
5.6.280.0000.02917.68
5.6.270.0050.02417.50
5.6.260.0050.02417.60
5.6.250.0040.02717.63
5.6.240.0020.02917.75
5.6.230.0060.03117.70
5.6.220.0030.04317.53
5.6.210.0070.03717.61
5.6.200.0020.03317.80
5.6.190.0090.02217.57
5.6.180.0030.02717.61
5.6.170.0050.02217.47
5.6.160.0050.02917.65
5.6.150.0050.02617.69
5.6.140.0060.02517.71
5.6.130.0030.02617.68
5.6.120.0000.03117.73
5.6.110.0030.02417.79
5.6.100.0030.03417.67
5.6.90.0050.02217.46
5.6.80.0020.02517.39
5.6.70.0020.02717.19
5.6.60.0030.02717.31
5.6.50.0060.02117.33
5.6.40.0040.02717.37
5.6.30.0100.02317.40
5.6.20.0020.02617.34
5.6.10.0060.03517.25
5.6.00.0040.02517.34

preferences:
73.71 ms | 401 KiB | 5 Q