3v4l.org

run code in 300+ PHP versions simultaneously
<?php $data = [ [ 'ID' => 16, 'begin_date' => new \DateTime('2016-01-01 UTC'), 'end_date' => new \DateTime('2016-11-30 UTC'), ], [ 'ID' => 33, 'begin_date' => new \DateTime('2016-01-04 UTC'), 'end_date' => new \DateTime('2016-02-29 UTC'), ], ]; // assume length >= 1 w/ previous validation // keep track of the in-progress leading element, assuming the first is leading to begin with $currentLeading = $data[0]; foreach($data as $index => $element) { if($element['begin_date'] > now()) { // first condition is true if ($index == 0) { echo "Error: Element cannot be the leading element"; // more likely return false if wrapped in a validation function } if($element['end_date'] > now()) { if ($element['end_date'] > $currentLeading['end_date']) { $currentLeading = $element; } } } } var_dump($currentLeading);

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.00617.00
8.3.50.0080.01021.17
8.3.40.0100.01018.92
8.3.30.0070.00718.78
8.3.20.0050.00220.25
8.3.10.0040.00423.61
8.3.00.0080.00021.89
8.2.180.0140.00716.50
8.2.170.0140.00022.96
8.2.160.0110.00420.35
8.2.150.0040.00424.18
8.2.140.0080.00024.66
8.2.130.0000.00726.16
8.2.120.0070.00720.88
8.2.110.0070.01020.99
8.2.100.0090.00317.93
8.2.90.0030.00519.21
8.2.80.0060.00318.03
8.2.70.0040.00417.88
8.2.60.0000.00917.93
8.2.50.0040.00418.07
8.2.40.0000.01022.18
8.2.30.0040.00419.54
8.2.20.0070.00417.94
8.2.10.0040.00418.13
8.2.00.0060.00318.24
8.1.280.0070.00725.92
8.1.270.0060.01221.94
8.1.260.0000.00826.35
8.1.250.0080.00028.09
8.1.240.0030.00621.04
8.1.230.0040.00819.22
8.1.220.0000.00917.74
8.1.210.0040.00418.77
8.1.200.0000.00917.60
8.1.190.0030.00517.38
8.1.180.0000.00818.10
8.1.170.0040.00418.77
8.1.160.0000.00720.81
8.1.150.0000.00820.59
8.1.140.0030.00519.63
8.1.130.0040.00417.65
8.1.120.0040.00417.46
8.1.110.0030.00717.61
8.1.100.0030.00517.61
8.1.90.0080.00017.48
8.1.80.0000.00817.51
8.1.70.0030.00317.52
8.1.60.0040.00417.59
8.1.50.0040.00417.63
8.1.40.0040.00417.63
8.1.30.0040.00417.64
8.1.20.0080.00017.66
8.1.10.0000.00817.54
8.1.00.0040.00417.64
8.0.300.0000.00718.77
8.0.290.0040.00416.88
8.0.280.0080.00018.46
8.0.270.0070.00017.28
8.0.260.0000.00717.18
8.0.250.0030.00317.18
8.0.240.0000.00717.09
8.0.230.0000.00717.18
8.0.220.0030.00516.98
8.0.210.0040.00417.11
8.0.200.0020.00517.02
8.0.190.0030.00316.99
8.0.180.0040.00417.15
8.0.170.0000.00716.96
8.0.160.0080.00017.02
8.0.150.0000.00717.07
8.0.140.0000.00717.04
8.0.130.0000.00613.43
8.0.120.0000.00816.95
8.0.110.0040.00417.05
8.0.100.0070.00016.97
8.0.90.0000.00717.14
8.0.80.0120.00917.02
8.0.70.0040.00417.04
8.0.60.0040.00417.09
8.0.50.0040.00416.94
8.0.30.0080.01217.29
8.0.20.0120.01217.41
8.0.10.0070.00017.21
8.0.00.0050.01416.98
7.4.330.0050.00016.66
7.4.320.0030.00316.69
7.4.300.0050.00316.59
7.4.290.0070.00016.66
7.4.280.0080.00016.53
7.4.270.0000.00616.66
7.4.260.0040.00416.58
7.4.250.0050.00216.47
7.4.240.0030.00516.70
7.4.230.0030.00316.61
7.4.220.0060.01016.65
7.4.210.0090.00916.62
7.4.200.0000.00716.70
7.4.160.0040.01316.79
7.4.150.0090.01217.40
7.4.140.0140.01517.86
7.4.130.0130.00816.72
7.4.120.0110.00816.68
7.4.110.0110.00616.50
7.4.100.0110.00616.67
7.4.90.0070.01416.60
7.4.80.0160.00319.39
7.4.70.0150.00416.77
7.4.60.0100.00516.73
7.4.50.0080.00316.64
7.4.40.0070.01016.72
7.4.30.0110.00716.41
7.4.00.0090.00615.03
7.3.330.0000.00613.25
7.3.320.0030.00313.44
7.3.310.0080.00016.57
7.3.300.0000.00816.55
7.3.290.0040.01116.45
7.3.280.0060.01216.46
7.3.270.0090.00917.40
7.3.260.0110.00616.53
7.3.250.0090.00816.56
7.3.240.0090.00916.65
7.3.230.0090.00916.66
7.3.210.0060.01116.51
7.3.200.0130.01016.53
7.3.190.0090.01216.55
7.3.180.0190.00016.43
7.3.170.0070.01116.48
7.3.160.0100.00616.81
7.3.120.0070.00814.85
7.3.110.0080.00614.91
7.3.100.0070.00714.86
7.3.90.0030.01015.13
7.3.80.0120.00315.11
7.3.70.0030.01015.10
7.3.60.0000.01215.03
7.3.50.0000.01814.82
7.3.40.0040.00814.95
7.3.30.0030.01014.93
7.3.20.0030.01316.43
7.3.10.0120.00316.69
7.3.00.0100.00416.56
7.2.330.0100.01016.95
7.2.320.0090.00916.90
7.2.310.0100.00616.68
7.2.300.0100.00716.76
7.2.290.0160.00016.95
7.2.240.0060.00614.97
7.2.230.0030.00915.33
7.2.220.0060.00615.21
7.2.210.0070.00714.87
7.2.200.0070.00715.29
7.2.190.0110.00315.18
7.2.180.0060.00915.21
7.2.170.0110.00714.98
7.2.160.0100.00715.33
7.2.150.0100.00717.11
7.2.140.0030.01417.16
7.2.130.0090.01016.91
7.2.120.0090.00816.86
7.2.110.0100.00816.93
7.2.100.0080.00916.92
7.2.90.0120.01016.96
7.2.80.0070.00916.90
7.2.70.0060.01116.89
7.2.60.0120.00416.92
7.2.50.0110.00817.07
7.2.40.0080.01116.95
7.2.30.0100.00816.89
7.2.20.0130.00616.93
7.2.10.0080.00817.07
7.2.00.0100.00617.52
7.1.330.0090.00315.72
7.1.320.0030.00915.93
7.1.310.0000.00915.79
7.1.300.0000.01115.83
7.1.290.0040.01115.73
7.1.280.0030.00715.61
7.1.270.0040.00815.73
7.1.260.0000.01515.91
7.1.250.0100.00615.73
7.1.200.0000.01115.89
7.1.100.0000.01318.21
7.1.70.0000.00817.39
7.1.60.0130.00619.40
7.1.50.0030.01717.07
7.1.00.0000.08022.42
7.0.200.0050.00216.92
7.0.60.0070.06721.68
7.0.50.0000.04717.83
7.0.40.0030.05320.12
7.0.30.0300.07720.18
7.0.20.0330.06720.09
7.0.10.0070.08720.01
7.0.00.0100.05320.17
5.6.210.0070.03720.52
5.6.200.0100.08318.13
5.6.190.0100.08320.61
5.6.180.0330.06020.41
5.6.170.0370.07320.42
5.6.160.0130.08020.50
5.6.150.0000.08718.17
5.6.140.0100.07718.18
5.6.130.0000.04718.14
5.6.120.0030.06721.11
5.6.110.0030.06320.99
5.6.100.0030.06721.11
5.6.90.0000.04320.96
5.6.80.0130.07320.48
5.5.350.4370.03020.35
5.5.340.0070.06717.95
5.5.330.0100.07020.21
5.5.320.0430.03320.26
5.5.310.0100.04720.26
5.5.300.0070.07018.01
5.5.290.0000.04318.02
5.5.280.0170.08020.97
5.5.270.0100.08320.95
5.5.260.0070.08720.86
5.5.250.0070.08720.68
5.5.240.0200.03720.26

preferences:
37.54 ms | 401 KiB | 5 Q