3v4l.org

run code in 300+ PHP versions simultaneously
<?php $dates = [ ['date_starts'=>'2021-03-22'], ['date_starts'=>'2022-04-22'], ['date_starts'=>'2023-05-22'] ]; $current_year = date('Y'); foreach ($dates as $dt) { $rates_results = [ ['price'=>255, 'year'=>'2021'], ['price'=>200, 'year'=>'2021'], ['price'=>300, 'year'=>'2023'] ]; // get the year from the start date. Since it's in YYYY-MM-DD format // we can just use substr $start_year = substr($dt['date_starts'], 0, 4); // find matching years in $rates_results $rate_keys = array_keys(array_column($rates_results, 'year'), $start_year); // any matches? if (empty($rate_keys)) { // no, use the values from the current year instead $rate_keys = array_keys(array_column($rates_results, 'year'), $current_year); } // get the actual rates $code = 1; $rates = array(); foreach ($rate_keys as $key) { $rates[] = [ 'custom' => $code, 'price' => $rates_results[$key]['price'], 'year' => $rates_results[$key]['year'] ]; } // output the rates print_r($rates); }

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.4.120.0120.00822.08
8.4.110.0120.00820.41
8.4.100.0030.00518.79
8.4.90.0100.00822.40
8.4.80.0100.00518.75
8.4.70.0100.00619.19
8.4.60.0070.00218.70
8.4.50.0060.01420.67
8.4.40.0130.00317.66
8.4.30.0100.00620.48
8.4.20.0130.00917.63
8.4.10.0130.00719.40
8.3.250.0130.00619.02
8.3.240.0050.00316.61
8.3.230.0160.00516.63
8.3.220.0040.00419.16
8.3.210.0120.00718.73
8.3.200.0120.00716.79
8.3.190.0040.00517.05
8.3.180.0090.00618.88
8.3.170.0150.00319.02
8.3.160.0140.00420.82
8.3.150.0060.01316.99
8.3.140.0030.00621.02
8.3.130.0000.00818.41
8.3.120.0030.00620.48
8.3.110.0090.00020.94
8.3.100.0100.00016.76
8.3.90.0060.00626.77
8.3.80.0060.00316.50
8.3.70.0150.00018.56
8.3.60.0120.00318.55
8.3.50.0080.01217.45
8.3.40.0040.01119.09
8.3.30.0100.01018.99
8.3.20.0000.00724.18
8.3.10.0040.00424.66
8.3.00.0030.00726.16
8.2.290.0080.01120.21
8.2.280.0050.00320.23
8.2.270.0150.00420.55
8.2.260.0110.00716.59
8.2.250.0120.00316.56
8.2.240.0100.01017.05
8.2.230.0040.00422.58
8.2.220.0030.00624.06
8.2.210.0110.00726.77
8.2.200.0060.00316.50
8.2.190.0100.00716.63
8.2.180.0100.01025.92
8.2.170.0080.00822.96
8.2.160.0090.00622.96
8.2.150.0040.00425.66
8.2.140.0060.00324.66
8.2.130.0040.00426.16
8.2.120.0060.00321.19
8.2.110.0100.00021.04
8.2.100.0000.01318.03
8.2.90.0040.00418.03
8.2.80.0000.00818.00
8.2.70.0060.00318.16
8.2.60.0090.00518.22
8.2.50.0040.00418.10
8.2.40.0050.00321.38
8.2.30.0050.00219.38
8.2.20.0040.00418.23
8.2.10.0080.00019.38
8.2.00.0000.00819.29
8.1.330.0110.00722.03
8.1.320.0120.00817.75
8.1.310.0060.00616.60
8.1.300.0090.00917.75
8.1.290.0090.00030.84
8.1.280.0120.00925.92
8.1.270.0060.00323.95
8.1.260.0080.00026.35
8.1.250.0030.00628.09
8.1.240.0090.00019.34
8.1.230.0080.00322.75
8.1.220.0060.00317.78
8.1.210.0050.00318.77
8.1.200.0080.00417.48
8.1.190.0030.00617.35
8.1.180.0060.00318.10
8.1.170.0000.00818.61
8.1.160.0070.00018.82
8.1.150.0060.00318.86
8.1.140.0040.00418.94
8.1.130.0030.00317.57
8.1.120.0040.00617.61
8.1.110.0040.00417.65
8.1.100.0040.00417.50
8.1.90.0000.00717.44
8.1.80.0000.00717.50
8.1.70.0040.00417.64
8.1.60.0000.00817.67
8.1.50.0030.00617.61
8.1.40.0080.00017.59
8.1.30.0070.00017.61
8.1.20.0000.00717.54
8.1.10.0040.00417.57
8.1.00.0000.00817.43
8.0.300.0000.00721.59
8.0.290.0070.00016.75
8.0.280.0030.00318.45
8.0.270.0000.00716.86
8.0.260.0030.00317.00
8.0.250.0040.00417.10
8.0.240.0030.00517.03
8.0.230.0040.00417.05
8.0.220.0030.00317.02
8.0.210.0040.00417.07
8.0.200.0050.00317.03
8.0.190.0030.00516.99
8.0.180.0080.00016.96
8.0.170.0040.00416.84
8.0.160.0030.00516.96
8.0.150.0040.00416.89
8.0.140.0050.00316.94
8.0.130.0030.00313.27
8.0.120.0000.00816.94
8.0.110.0050.00316.90
8.0.100.0040.00416.74
8.0.90.0040.00417.00
8.0.80.0070.00916.87
8.0.70.0000.00717.05
8.0.60.0040.00416.79
8.0.50.0000.00816.91
8.0.30.0110.00617.00
8.0.20.0060.01317.39
8.0.10.0090.00917.24
8.0.00.0040.01217.19
7.4.330.0040.00015.55
7.4.320.0030.00316.66
7.4.300.0030.00316.56
7.4.290.0030.00516.61
7.4.280.0030.00516.66
7.4.270.0060.00016.66
7.4.260.0030.00313.27
7.4.250.0070.00016.54
7.4.240.0020.00516.58
7.4.230.0070.00016.55
7.4.220.0040.00316.72
7.4.210.0070.00816.57
7.4.200.0040.00416.64
7.4.160.0060.01016.59
7.4.150.0080.01116.77
7.4.140.0060.00916.68
7.4.130.0070.01016.61
7.4.120.0120.00816.48
7.4.110.0160.00016.62
7.4.100.0070.00716.49
7.4.90.0090.00616.49
7.4.80.0000.01616.63
7.4.70.0100.00616.52
7.4.60.0110.00516.66
7.4.50.0070.01016.50
7.4.40.0070.01016.51
7.4.30.0070.01016.72
7.4.20.0160.00016.71
7.4.10.0110.00516.27
7.4.00.0100.01016.63
7.3.330.0030.00316.20
7.3.320.0050.00013.31
7.3.310.0060.00316.45
7.3.300.0000.00616.23
7.3.290.0060.00916.38
7.3.270.0040.01116.62
7.3.260.0130.00316.64
7.3.250.0100.00516.50
7.3.240.0090.00616.56
7.3.230.0120.00316.50
7.3.220.0090.00616.65
7.3.210.0120.00316.29
7.3.200.0070.01016.68
7.3.190.0030.01216.35
7.3.180.0110.00716.59
7.3.170.0150.00016.36
7.3.160.0130.00316.33
7.3.150.0150.00016.44
7.3.140.0200.00316.13
7.3.130.0140.00916.11
7.3.120.0080.01216.04
7.3.110.0110.00416.51
7.3.100.0150.00016.70
7.3.90.0120.00316.49
7.3.80.0090.00616.42
7.3.70.0090.00916.42
7.3.60.0080.00816.37
7.3.50.0030.01316.45
7.3.40.0130.00716.46
7.3.30.0100.00716.54
7.3.20.0100.00616.34
7.3.10.0080.00816.45
7.3.00.0080.00816.65

preferences:
132.09 ms | 403 KiB | 5 Q