3v4l.org

run code in 300+ PHP versions simultaneously
<?php function extractPatterns(array $rules) : array { $postcodes = []; foreach ($rules as $rule) { if (preg_match('/^([A-Z]{1,2})([0-9]{1,2})-([0-9]{1,2})$/', trim($rule), $matches)) { for ($i = $matches[2]; $i <= $matches[3]; $i++) { $postcodes[] = sprintf('%s%s', $matches[1], $i); } continue; } if (preg_match('([A-Z]{1,2}[0-9]{1,2})', $rule, $matches)) { $postcodes[] = $matches[0]; continue; } if (preg_match('[A-Z]{1,2})', $rule, $matches)) { $postcodes[] = $matches[0]; continue; } } return $postcodes; } $tests = [ [ 'rules' => 'AB41-56, FK19-21, NG12', 'expected' => [ 'AB41', 'AB42', 'AB43', 'AB44', 'AB45', 'AB46', 'AB47', 'AB48', 'AB49', 'AB50', 'AB51', 'AB52', 'AB53', 'AB54', 'AB55', 'AB56', 'FK19', 'FK20', 'FK21', 'NG12' ] ], [ 'rules' => 'HU1, W1-5', 'expected' => [ 'HU1', 'W1', 'W2', 'W3', 'W4', 'W5' ] ] ]; foreach ($tests as $test) { assert(extractPatterns(explode(',', $test['rules'])) == $test['expected']); }

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.0070.00716.50
8.3.50.0070.00716.72
8.3.40.0150.00318.92
8.3.30.0040.01219.04
8.3.20.0080.00020.29
8.3.10.0080.00021.89
8.3.00.0080.00020.16
8.2.180.0120.00616.63
8.2.170.0070.01422.96
8.2.160.0070.00720.39
8.2.150.0040.00424.18
8.2.140.0080.00024.66
8.2.130.0040.00421.30
8.2.120.0040.00426.35
8.2.110.0030.00819.30
8.2.100.0040.00818.34
8.2.90.0030.00519.35
8.2.80.0040.00417.97
8.2.70.0040.00417.75
8.2.60.0080.00018.03
8.2.50.0030.00518.10
8.2.40.0040.00420.55
8.2.30.0030.00621.06
8.2.20.0050.00318.23
8.2.10.0040.00418.05
8.2.00.0000.00718.17
8.1.280.0100.00725.92
8.1.270.0000.00723.99
8.1.260.0050.00326.35
8.1.250.0030.00528.09
8.1.240.0090.00023.96
8.1.230.0050.00817.64
8.1.220.0000.00817.78
8.1.210.0050.00318.77
8.1.200.0000.01017.35
8.1.190.0040.00417.35
8.1.180.0080.00018.10
8.1.170.0050.00320.50
8.1.160.0070.00019.02
8.1.150.0080.00020.70
8.1.140.0040.00419.63
8.1.130.0070.00018.98
8.1.120.0000.00717.54
8.1.110.0070.00017.46
8.1.100.0040.00417.62
8.1.90.0080.00017.64
8.1.80.0000.00817.61
8.1.70.0000.00817.61
8.1.60.0070.00317.76
8.1.50.0050.00517.67
8.1.40.0040.00417.57
8.1.30.0040.00417.76
8.1.20.0040.00417.82
8.1.10.0060.00317.78
8.1.00.0040.00417.61
8.0.300.0040.00418.77
8.0.290.0070.00017.13
8.0.280.0050.00318.44
8.0.270.0030.00317.21
8.0.260.0030.00316.96
8.0.250.0030.00517.23
8.0.240.0000.00717.15
8.0.230.0070.00017.16
8.0.220.0030.00617.12
8.0.210.0040.00417.12
8.0.200.0030.00317.19
8.0.190.0040.00417.16
8.0.180.0060.00317.19
8.0.170.0040.00417.16
8.0.160.0060.00317.15
8.0.150.0060.00317.05
8.0.140.0000.00717.09
8.0.130.0060.00013.54
8.0.120.0030.00517.02
8.0.110.0040.00417.00
8.0.100.0040.00417.19
8.0.90.0070.00017.10
8.0.80.0060.00917.10
8.0.70.0040.00417.23
8.0.60.0040.00417.06
8.0.50.0030.00517.17
8.0.30.0050.01217.33
8.0.20.0090.01117.43
8.0.10.0060.00317.35
8.0.00.0110.01416.93
7.4.330.0000.00515.55
7.4.320.0030.00316.84
7.4.300.0040.00416.82
7.4.290.0070.00016.73
7.4.280.0000.00716.82
7.4.270.0000.00716.75
7.4.260.0000.00716.75
7.4.250.0060.00316.80
7.4.240.0000.00716.82
7.4.230.0070.00016.71
7.4.220.0060.01216.78
7.4.210.0090.01216.68
7.4.200.0000.00816.83
7.4.160.0120.00516.70
7.4.150.0080.01117.40
7.4.140.0130.00817.86
7.4.130.0130.01016.79
7.4.120.0090.01116.74
7.4.110.0080.00816.57
7.4.100.0070.01116.61
7.4.90.0090.01516.52
7.4.80.0110.01119.39
7.4.70.0130.00616.77
7.4.60.0130.00316.71
7.4.50.0130.00316.47
7.4.40.0130.01016.76
7.4.30.0080.00816.70
7.4.00.0070.01015.26
7.3.330.0050.00013.57
7.3.320.0060.00013.61
7.3.310.0040.00416.49
7.3.300.0030.00316.52
7.3.290.0040.01116.51
7.3.280.0060.01016.52
7.3.270.0100.00717.40
7.3.260.0130.00616.75
7.3.250.0110.00816.56
7.3.240.0120.00716.78
7.3.230.0090.00916.58
7.3.210.0040.01516.75
7.3.200.0110.00916.59
7.3.190.0030.01816.71
7.3.180.0070.01016.55
7.3.170.0090.01016.90
7.3.160.0100.01016.71
7.2.330.0070.01016.97
7.2.320.0060.01116.93
7.2.310.0130.00616.89
7.2.300.0000.01716.72
7.2.290.0070.01016.92
7.2.60.0000.01316.80
7.2.00.0070.01719.63
7.1.200.0000.01115.92
7.1.100.0030.00618.38
7.1.70.0340.01415.46
7.1.60.0370.01633.63
7.1.50.0310.01734.80
7.1.40.0140.01834.93
7.1.30.0400.01333.01
7.1.20.0140.02135.06
7.1.10.0080.00616.72
7.1.00.0060.01216.83
7.0.200.0290.00616.88
7.0.190.0330.01315.18
7.0.180.0120.00316.55
7.0.170.0260.00814.78
7.0.160.0310.00714.79
7.0.150.0350.00714.63
7.0.140.0030.01816.66
7.0.130.0220.00615.01
7.0.120.0080.00816.86
7.0.110.0180.01115.00
7.0.100.0220.00614.63
7.0.90.0170.01014.77
7.0.80.0030.01116.48
7.0.70.0230.01014.86
7.0.60.0120.00316.34
7.0.50.0230.01214.81
7.0.40.0040.01116.63
7.0.30.0080.00816.74
7.0.20.0090.00616.53
7.0.10.0060.00916.75
7.0.00.0080.01216.54

preferences:
35.51 ms | 401 KiB | 5 Q