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 23:59:59 [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 23:59:59'], // overlapping ['start' => '2016-01-12 00:00:00', 'end' => '2016-01-13 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 uptime 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++) { $uptime_start = $incidents[$i]['end']; $uptime_end = $incidents[$i]['start']; for($j = $i+1;$j < sizeof($incidents);$j++) { // this logic doesnt work as expected! if(strtotime($uptime_start) > strtotime($incidents[$j]['start']) && strtotime($uptime_start) < strtotime($incidents[$j]['end']) && strtotime($uptime_start) < strtotime($incidents[$j+1]['start'])) { $uptime_start = $incidents[$j]['end']; $uptime_end = $incidents[$j+1]['start']; array_push($uptime, ['start' => $uptime_start, 'end' => $uptime_end]); } } // Saving for last period if(strtotime($incidents[$i]['end']) > strtotime($last_end)) { $last_end = $incidents[$i]['end']; } } // Last uptime 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.5.10.0070.01020.14
8.5.00.0120.01021.84
8.4.150.0020.00014.05
8.4.140.0120.00917.64
8.4.130.0160.00417.89
8.4.120.0070.00322.52
8.4.110.0060.00422.48
8.4.100.0140.00618.06
8.4.90.0120.00918.77
8.4.80.0150.00418.11
8.4.70.0040.00518.07
8.4.60.0110.00918.92
8.4.50.0160.00418.72
8.4.40.0060.01319.35
8.4.30.0170.00319.56
8.4.20.0170.00317.79
8.4.10.0130.00319.43
8.3.280.0140.00818.62
8.3.270.0130.00716.94
8.3.260.0050.00417.00
8.3.250.0120.00618.96
8.3.240.0100.00716.91
8.3.230.0080.01216.83
8.3.220.0090.00619.02
8.3.210.0100.00918.62
8.3.200.0070.00216.94
8.3.190.0080.01017.13
8.3.180.0140.00516.85
8.3.170.0130.00617.13
8.3.160.0040.00418.52
8.3.150.0000.00916.88
8.3.140.0040.01117.60
8.3.130.0090.00018.47
8.3.120.0130.00619.14
8.3.110.0070.00720.94
8.3.100.0070.00316.66
8.3.90.0070.01126.77
8.3.80.0030.00718.81
8.3.70.0140.00016.63
8.3.60.0060.00916.71
8.3.50.0080.01122.05
8.3.40.0090.00618.98
8.3.30.0140.00018.97
8.3.20.0030.00518.98
8.3.10.0080.00021.96
8.3.00.0040.00421.75
8.2.290.0070.00520.22
8.2.280.0120.00818.46
8.2.270.0120.00617.54
8.2.260.0050.00316.50
8.2.250.0080.00017.04
8.2.240.0040.00418.77
8.2.230.0080.00422.58
8.2.220.0070.00437.54
8.2.210.0060.00326.77
8.2.200.0030.00617.00
8.2.190.0090.00616.75
8.2.180.0080.00825.92
8.2.170.0110.00422.96
8.2.160.0070.00722.26
8.2.150.0080.00024.18
8.2.140.0060.00324.66
8.2.130.0040.00419.95
8.2.120.0030.00526.35
8.2.110.0050.00521.02
8.2.100.0040.00718.34
8.2.90.0030.00619.22
8.2.80.0040.00418.22
8.2.70.0080.00017.75
8.2.60.0040.00417.88
8.2.50.0000.00917.75
8.2.40.0000.00820.59
8.2.30.0030.00621.22
8.2.20.0000.00718.22
8.2.10.0080.00018.10
8.2.00.0000.00718.02
8.1.330.0090.00921.92
8.1.320.0090.01016.56
8.1.310.0100.00718.63
8.1.300.0000.01618.04
8.1.290.0060.00330.84
8.1.280.0070.00725.92
8.1.270.0040.00422.14
8.1.260.0000.00728.09
8.1.250.0040.00428.09
8.1.240.0000.01119.32
8.1.230.0000.01117.89
8.1.220.0030.00617.78
8.1.210.0030.00718.77
8.1.200.0030.00617.47
8.1.190.0030.00517.36
8.1.180.0000.00918.10
8.1.170.0040.00418.84
8.1.160.0000.00723.92
8.1.150.0030.00720.61
8.1.140.0000.00719.67
8.1.130.0060.00317.72
8.1.120.0080.00017.68
8.1.110.0030.00517.68
8.1.100.0000.00717.73
8.1.90.0040.00417.68
8.1.80.0040.00417.69
8.1.70.0070.00017.61
8.1.60.0000.00817.77
8.1.50.0000.00817.73
8.1.40.0000.00817.57
8.1.30.0030.00617.77
8.1.20.0050.00317.62
8.1.10.0050.00217.59
8.1.00.0030.00817.56
8.0.300.0070.00018.77
8.0.290.0040.00416.86
8.0.280.0040.00418.43
8.0.270.0000.00717.37
8.0.260.0070.00016.96
8.0.250.0070.00017.17
8.0.240.0000.00817.16
8.0.230.0000.00717.15
8.0.220.0070.00017.15
8.0.210.0030.00317.03
8.0.200.0040.00417.20
8.0.190.0000.00817.20
8.0.180.0000.00817.04
8.0.170.0040.00417.11
8.0.160.0000.00717.06
8.0.150.0040.00417.03
8.0.140.0000.00817.01
8.0.130.0030.00313.56
8.0.120.0040.00417.09
8.0.110.0040.00417.10
8.0.100.0000.00717.16
8.0.90.0000.00717.08
8.0.80.0100.01017.10
8.0.70.0040.00417.00
8.0.60.0000.00817.19
8.0.50.0040.00416.94
8.0.30.0090.00817.30
8.0.20.0110.00917.42
8.0.10.0000.00717.04
8.0.00.0180.00016.90
7.4.330.0050.00015.55
7.4.320.0000.00616.75
7.4.300.0030.00316.62
7.4.290.0000.00716.71
7.4.280.0030.00716.60
7.4.270.0070.00016.68
7.4.260.0000.00716.74
7.4.250.0000.00716.73
7.4.240.0000.00716.75
7.4.230.0020.00516.59
7.4.220.0060.01616.72
7.4.210.0070.01016.73
7.4.200.0000.00816.84
7.4.160.0080.00816.81
7.4.150.0140.00617.40
7.4.140.0110.00617.86
7.4.130.0130.00416.73
7.4.120.0100.00816.59
7.4.110.0130.01016.72
7.4.100.0100.00716.87
7.4.90.0120.00616.64
7.4.80.0140.01119.39
7.4.70.0060.01116.65
7.4.60.0060.01216.63
7.4.50.0040.01116.81
7.4.40.0130.00316.68
7.4.30.0170.00616.72
7.4.00.0080.00815.00
7.3.330.0030.00313.39
7.3.320.0000.00513.32
7.3.310.0000.00816.55
7.3.300.0080.00016.55
7.3.290.0000.00616.48
7.3.280.0060.01116.45
7.3.270.0100.00717.40
7.3.260.0080.00916.82
7.3.250.0080.00916.70
7.3.240.0150.00516.55
7.3.230.0110.00716.73
7.3.210.0100.00716.86
7.3.200.0090.00916.80
7.3.190.0060.01516.61
7.3.180.0100.00716.70
7.3.170.0150.00316.83
7.3.160.0180.00316.72
7.3.120.0100.01014.80
7.3.110.0070.01115.23
7.3.100.0070.01314.82
7.3.90.0030.01015.16
7.3.80.0090.00315.12
7.3.70.0070.00415.05
7.3.60.0030.00614.87
7.3.50.0060.01015.18
7.3.40.0160.00014.78
7.3.30.0070.00714.98
7.3.20.0080.00816.94
7.3.10.0060.01016.84
7.3.00.0030.00916.46
7.2.330.0090.01016.78
7.2.320.0030.01516.57
7.2.310.0100.00716.92
7.2.300.0100.01416.79
7.2.290.0150.00916.71
7.2.250.0100.01015.42
7.2.240.0100.00715.37
7.2.230.0100.01015.20
7.2.220.0050.00815.29
7.2.210.0070.00715.49
7.2.200.0030.01115.29
7.2.190.0040.01115.30
7.2.180.0030.01515.19
7.2.170.0030.01615.04
7.2.60.0060.00617.17
7.1.330.0100.00716.21
7.1.320.0040.00415.99
7.1.310.0120.00316.02
7.1.300.0110.00716.16
7.1.290.0060.01315.97
7.1.280.0030.01015.88
7.1.270.0090.00616.11
7.1.260.0040.00715.73
7.1.200.0070.00715.90
7.1.70.0040.00417.38
7.1.60.0040.00717.60
7.1.00.0130.06722.51
7.0.200.0550.00614.79
7.0.120.0100.08322.01
7.0.110.0030.09022.03
7.0.100.0100.07022.17
7.0.90.0130.05722.12
7.0.80.0170.05022.06
7.0.70.0030.06022.19
7.0.60.0170.05722.11
7.0.50.0030.06022.12
7.0.40.0070.05722.07
7.0.30.0100.07722.15
7.0.20.0270.05722.08
7.0.10.0100.07322.14
7.0.00.0030.08022.05
5.6.270.0070.06721.05
5.6.260.0070.08720.89
5.6.250.0100.06320.85
5.6.240.0070.06020.82
5.6.230.0200.05021.02
5.6.220.0030.06320.87
5.6.210.0200.04720.96
5.6.200.0030.08320.88
5.6.190.0170.05021.00
5.6.180.0100.07321.01
5.6.170.0070.06321.10
5.6.160.0100.07721.10
5.6.150.0230.06021.07
5.6.140.0070.08021.03
5.6.130.0100.06721.07
5.6.120.0170.07321.07
5.6.110.0130.06020.80
5.6.100.0200.07320.99
5.6.90.0100.05720.97
5.6.80.0130.07320.26
5.6.70.0070.05720.21
5.6.60.0130.05720.23
5.6.50.0100.05320.23
5.6.40.0170.05020.31
5.6.30.0030.06320.22
5.6.20.0070.05720.40
5.6.10.0100.05020.29
5.6.00.0030.06020.28

preferences:
38.18 ms | 403 KiB | 5 Q