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[$i]['end']) < strtotime($incidents[$j]['start'])) { if(strtotime($incidents[$j]['end']) > strtotime($last_end_j)) { $last_end_j = $incidents[$j]['end']; } 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.0120.00316.63
8.3.50.0140.00718.23
8.3.40.0000.01418.96
8.3.30.0110.00318.87
8.3.20.0080.00018.96
8.3.10.0000.00821.73
8.3.00.0040.00421.85
8.2.180.0110.00417.00
8.2.170.0110.00422.96
8.2.160.0130.00722.11
8.2.150.0070.00024.18
8.2.140.0000.00824.66
8.2.130.0040.00426.16
8.2.120.0000.00721.18
8.2.110.0070.00322.25
8.2.100.0030.00918.02
8.2.90.0000.00818.17
8.2.80.0040.00417.97
8.2.70.0050.00318.05
8.2.60.0040.00417.92
8.2.50.0000.00718.22
8.2.40.0050.00220.66
8.2.30.0000.00719.41
8.2.20.0050.00218.16
8.2.10.0060.00318.09
8.2.00.0000.00817.84
8.1.280.0130.01025.92
8.1.270.0070.00023.79
8.1.260.0000.00826.35
8.1.250.0090.00628.09
8.1.240.0060.00323.84
8.1.230.0040.00819.04
8.1.220.0080.00017.76
8.1.210.0060.00318.77
8.1.200.0030.00617.36
8.1.190.0040.00417.47
8.1.180.0000.00818.10
8.1.170.0090.00018.78
8.1.160.0040.00424.02
8.1.150.0040.00420.73
8.1.140.0040.00419.67
8.1.130.0070.00017.85
8.1.120.0040.00417.73
8.1.110.0050.00217.56
8.1.100.0000.00717.56
8.1.90.0000.00717.75
8.1.80.0050.00217.66
8.1.70.0000.00717.70
8.1.60.0090.00017.75
8.1.50.0030.00517.73
8.1.40.0000.00917.68
8.1.30.0040.00417.71
8.1.20.0040.00417.68
8.1.10.0000.00717.75
8.1.00.0120.00017.59
8.0.300.0070.00020.16
8.0.290.0040.00417.13
8.0.280.0030.00518.60
8.0.270.0030.00317.36
8.0.260.0040.00417.24
8.0.250.0070.00017.07
8.0.240.0000.00717.20
8.0.230.0000.00717.08
8.0.220.0050.00317.11
8.0.210.0000.00717.03
8.0.200.0050.00317.09
8.0.190.0030.00617.08
8.0.180.0070.00017.20
8.0.170.0050.00317.05
8.0.160.0000.00717.19
8.0.150.0040.00417.09
8.0.140.0040.00416.97
8.0.130.0030.00313.44
8.0.120.0060.00317.07
8.0.110.0080.00017.04
8.0.100.0040.00417.00
8.0.90.0030.00617.03
8.0.80.0060.00917.10
8.0.70.0040.00417.11
8.0.60.0000.00716.95
8.0.50.0040.00416.97
8.0.30.0110.01017.41
8.0.20.0110.01017.40
8.0.10.0070.00017.18
8.0.00.0060.01117.00
7.4.330.0020.00215.55
7.4.320.0060.00016.60
7.4.300.0000.00616.74
7.4.290.0000.00716.74
7.4.280.0050.00316.52
7.4.270.0040.00416.72
7.4.260.0080.00016.67
7.4.250.0040.00416.64
7.4.240.0000.00716.66
7.4.230.0070.00016.68
7.4.220.0110.00716.70
7.4.210.0070.00716.74
7.4.200.0030.00316.79
7.4.160.0090.00816.47
7.4.150.0110.00717.40
7.4.140.0090.01017.86
7.4.130.0110.00716.63
7.4.120.0120.00416.81
7.4.110.0090.00916.64
7.4.100.0100.01316.60
7.4.90.0140.00316.81
7.4.80.0040.02019.39
7.4.70.0080.00816.59
7.4.60.0070.01016.48
7.4.50.0140.00316.80
7.4.40.0100.00716.80
7.4.30.0070.01116.73
7.4.00.0030.01015.04
7.3.330.0030.00213.35
7.3.320.0000.00513.32
7.3.310.0070.00016.46
7.3.300.0020.00516.56
7.3.290.0070.01116.50
7.3.280.0070.01116.48
7.3.270.0120.00617.40
7.3.260.0100.00816.74
7.3.250.0090.01016.61
7.3.240.0160.00516.50
7.3.230.0110.00716.53
7.3.210.0140.00316.55
7.3.200.0070.01016.71
7.3.190.0060.00916.60
7.3.180.0070.01116.59
7.3.170.0080.00916.65
7.3.160.0070.01116.43
7.3.10.0120.00316.91
7.3.00.0030.01016.79
7.2.330.0030.01516.74
7.2.320.0070.01116.96
7.2.310.0100.00716.70
7.2.300.0110.01216.81
7.2.290.0070.01116.65
7.2.130.0110.00416.95
7.2.120.0040.00417.23
7.2.110.0060.00916.99
7.2.100.0100.00017.09
7.2.90.0090.00617.02
7.2.80.0100.00717.10
7.2.70.0030.01617.09
7.2.60.0070.00716.91
7.2.50.0020.01217.09
7.2.40.0030.01317.11
7.2.30.0060.00617.26
7.2.20.0070.00717.13
7.2.10.0030.01016.99
7.2.00.0070.00718.29
7.1.250.0030.00515.80
7.1.200.0040.01215.96
7.1.70.0000.00717.11
7.1.60.0170.00717.07
7.1.00.0000.08022.40
7.0.200.0400.00614.67
7.0.120.0070.05722.05
7.0.110.0070.05721.93
7.0.100.0030.06022.08
7.0.90.0070.07022.07
7.0.80.0030.05722.01
7.0.70.0030.06022.13
7.0.60.0030.06022.11
7.0.50.0070.07722.05
7.0.40.0030.06322.07
7.0.30.0070.06722.11
7.0.20.0070.07022.05
7.0.10.0070.05721.97
7.0.00.0170.04322.14
5.6.270.0030.06021.06
5.6.260.0030.05720.97
5.6.250.0030.06020.98
5.6.240.0030.06020.80
5.6.230.0030.06020.87
5.6.220.0070.05720.85
5.6.210.0130.05020.95
5.6.200.0100.07721.03
5.6.190.0100.06020.80
5.6.180.0030.05720.93
5.6.170.0130.07021.03
5.6.160.0100.05021.02
5.6.150.0100.06020.84
5.6.140.0070.06020.80
5.6.130.0130.05021.00
5.6.120.0130.05720.88
5.6.110.0070.05720.79
5.6.100.0130.05320.85
5.6.90.0070.05320.78
5.6.80.0130.04720.40
5.6.70.0070.05020.38
5.6.60.0000.06020.44
5.6.50.0030.05720.47
5.6.40.0170.04320.29
5.6.30.0100.05720.20
5.6.20.0130.07320.11
5.6.10.0100.05720.35
5.6.00.0070.05020.09

preferences:
58.06 ms | 400 KiB | 5 Q