3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr_postcode_regexes = [ 'uk' => [ // Should match any *valid* UK postcode ['[A-Z]', '[A-Z]?', '[0-9]', '[0-9A-Z]?'], ], 'offshore' => [ ['A', 'B', '3', '[0-8]'], // AB30-38 ['A', 'B', '4', '[1-9]'], // AB41-49 ['A', 'B', '5', '[0-6]'], // AB50-56 ['F', 'K', '1', '[789]'], // FK17-19 ['F', 'K', '2', '[01]'], // FK20-21 ['G', '8', '3'], // G83 ['G', 'Y', '9'], // GY9 ['H', 'S', '[1-9]'], // HS1-9 ['I', 'M', '[0-9]', '[0-9A-Z]?'], // IM ['I', 'M', '[0-9]', '[0-9A-Z]?'], // IV ['K', 'A', '2', '[89]'], // KA27-28 ['K', 'W', '[0-9]', '[0-9]?'], // KW0-99 ['P', 'A', '[2-9]', '[0-9]'], // PA20-99 ['P', 'H', '1', '[5-9]'], // PH15-19 ['P', 'H', '[2-9]', '[0-9]'], // PH20-99 ['T', 'R', '2', '[1-5]'], // TR21-25 ['Z', 'E', '[0-9]', '[0-9A-Z]?'], // ZE ], 'ni' => [ ['B', 'T', '[0-9]', '[0-9A-Z]?'], // ZE ] ]; // Turn the readable-ish map above into actual regexes // It's important that all regexes match only full, valid postcodes, as prefix matching can be ambiguous. foreach ($arr_postcode_regexes as $str_id => $arr_parts) { $arr_temp = []; foreach ($arr_parts as $arr_part) { $arr_temp[] = implode('\s*', $arr_part) . '\s*[0-9]\s*[A-Z]\s*[A-Z]'; } $arr_postcode_regexes[$str_id] = '^\s*(' . implode('|', $arr_temp) . ')\s*$'; } $tests = [ 'M65GQ', 'G83GH', 'G833GH', 'IM14GF', 'TR207HG', 'TR217HG', 'TR21HG', 'BT12HG', ]; foreach ($tests as $test) { echo "$test:\n"; foreach ($arr_postcode_regexes as $name => $expr) { echo " $name: " . (preg_match('/' . $expr . '/i', $test) ? 'yes' : 'no') . "\n"; } echo "\n"; } var_dump($arr_postcode_regexes);

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.0090.01318.80
8.3.50.0090.00923.02
8.3.40.0040.01119.34
8.3.30.0110.00419.34
8.3.20.0040.00420.46
8.3.10.0050.00321.98
8.3.00.0040.00418.29
8.2.180.0060.01518.81
8.2.170.0090.00622.96
8.2.160.0030.01420.62
8.2.150.0080.00024.18
8.2.140.0080.00024.66
8.2.130.0040.00426.16
8.2.120.0080.00020.99
8.2.110.0000.01121.18
8.2.100.0090.00318.28
8.2.90.0060.00319.52
8.2.80.0000.00817.97
8.2.70.0090.00017.88
8.2.60.0030.01017.93
8.2.50.0060.00318.07
8.2.40.0030.00518.34
8.2.30.0040.00418.30
8.2.20.0000.00818.01
8.2.10.0040.00418.37
8.2.00.0040.00418.10
8.1.280.0040.01525.92
8.1.270.0030.00624.05
8.1.260.0080.00026.35
8.1.250.0060.00328.09
8.1.240.0140.00021.01
8.1.230.0060.00621.03
8.1.220.0000.00917.90
8.1.210.0060.00619.04
8.1.200.0000.01017.72
8.1.190.0050.00317.72
8.1.180.0000.00819.20
8.1.170.0090.00018.71
8.1.160.0000.00822.14
8.1.150.0030.00619.13
8.1.140.0040.00417.66
8.1.130.0000.00918.00
8.1.120.0000.00717.70
8.1.110.0000.00817.73
8.1.100.0070.00017.64
8.1.90.0120.00017.60
8.1.80.0000.00817.55
8.1.70.0000.00717.64
8.1.60.0090.00017.88
8.1.50.0030.00617.82
8.1.40.0040.00417.67
8.1.30.0030.00617.81
8.1.20.0030.00617.86
8.1.10.0030.00617.83
8.1.00.0030.00617.69
8.0.300.0080.00020.11
8.0.290.0030.00617.00
8.0.280.0000.00818.55
8.0.270.0040.00417.29
8.0.260.0000.00717.27
8.0.250.0030.00317.14
8.0.240.0000.00917.17
8.0.230.0050.00217.19
8.0.220.0030.00317.09
8.0.210.0000.00717.12
8.0.200.0000.00717.20
8.0.190.0040.00417.09
8.0.180.0080.00017.16
8.0.170.0080.00017.23
8.0.160.0000.00817.01
8.0.150.0040.00417.18
8.0.140.0000.00816.99
8.0.130.0000.00613.54
8.0.120.0030.00617.08
8.0.110.0040.00417.06
8.0.100.0050.00317.24
8.0.90.0000.00817.07
8.0.80.0060.01217.19
8.0.70.0080.00017.07
8.0.60.0030.00617.11
8.0.50.0060.00317.16
8.0.30.0150.00717.45
8.0.20.0050.01517.53
8.0.10.0000.00817.13
8.0.00.0090.01217.02
7.4.330.0000.00515.16
7.4.320.0000.00716.98
7.4.300.0030.00316.97
7.4.290.0040.00416.76
7.4.280.0050.00316.96
7.4.270.0000.00716.96
7.4.260.0040.00816.85
7.4.250.0000.00816.84
7.4.240.0020.00516.88
7.4.230.0070.00016.81
7.4.220.0120.00616.97
7.4.210.0080.00816.91
7.4.200.0040.00316.78
7.4.160.0140.00416.94
7.4.150.0090.01117.40
7.4.140.0050.01317.86
7.4.130.0070.01216.87
7.4.120.0060.01516.79
7.4.110.0120.00617.02
7.4.100.0130.00516.91
7.4.90.0110.00716.83
7.4.80.0150.00619.39
7.4.70.0130.00416.99
7.4.60.0150.00816.82
7.4.50.0000.00716.70
7.4.40.0140.00316.83
7.4.30.0060.01217.02
7.4.00.0110.00715.20
7.3.330.0030.00413.28
7.3.320.0030.00313.29
7.3.310.0040.00416.64
7.3.300.0070.00016.55
7.3.290.0070.00716.51
7.3.280.0110.00916.57
7.3.270.0100.01017.40
7.3.260.0060.01216.62
7.3.250.0130.00616.72
7.3.240.0100.01316.93
7.3.230.0120.00616.86
7.3.210.0120.00616.73
7.3.200.0040.01519.39
7.3.190.0070.01016.65
7.3.180.0110.00616.48
7.3.170.0140.00316.66
7.3.160.0000.01616.62
7.3.120.0030.00915.39
7.2.330.0100.01016.77
7.2.320.0110.00616.83
7.2.310.0140.00316.95
7.2.300.0070.01116.87
7.2.290.0000.01917.00
7.2.00.0070.01019.42
7.1.100.0070.00718.25
7.1.70.0030.00717.49
7.1.60.0130.01319.40
7.1.50.0000.02517.29
7.1.00.0100.07022.53
7.0.200.0000.00716.75
7.0.140.0130.06322.07
7.0.60.0130.07720.16
7.0.50.0000.04317.98
7.0.40.0170.07720.49
7.0.30.0330.08020.09
7.0.20.0200.05320.07
7.0.10.0100.04020.27
7.0.00.0100.06320.19
5.6.280.0070.07021.11
5.6.210.0030.04020.56
5.6.200.0100.04718.19
5.6.190.0170.05320.40
5.6.180.3300.04020.27
5.6.170.0200.07320.48
5.6.160.0100.04720.37
5.6.150.0030.06718.16
5.6.140.0030.04318.13
5.6.130.0070.04018.14
5.6.120.0100.04021.09
5.6.110.0130.09021.16
5.6.100.0000.05321.05
5.6.90.0070.08721.00
5.6.80.0130.07320.40
5.5.350.0270.08020.42
5.5.340.0130.08017.88
5.5.330.0000.04320.29
5.5.320.2870.04720.34
5.5.310.0300.07020.29
5.5.300.0170.07017.98
5.5.290.0000.05317.95
5.5.280.0070.08720.75
5.5.270.0070.04320.78
5.5.260.0170.07320.86
5.5.250.0030.04020.52
5.5.240.4200.03720.13
5.4.450.0330.03719.21
5.4.440.0400.04719.46
5.4.430.0200.04319.48
5.4.420.0630.04319.10
5.4.410.0400.03319.08
5.4.400.0570.04019.14
5.4.390.0530.04718.81
5.4.380.0600.08318.61
5.4.370.0300.07718.50
5.4.360.0330.05718.70
5.4.350.0430.06318.70
5.4.340.1100.05318.73
5.4.320.0080.04112.49
5.4.310.0090.04212.49
5.4.300.0030.03912.49
5.4.290.0070.04312.49
5.4.280.0070.03412.38
5.4.270.0090.03812.38
5.4.260.0050.04112.39
5.4.250.0030.04212.39
5.4.240.0030.03912.39
5.4.230.0070.03712.38
5.4.220.0060.03612.38
5.4.210.0060.03612.38
5.4.200.0070.04312.38
5.4.190.0080.03512.37
5.4.180.0060.03512.38
5.4.170.0100.03612.39
5.4.160.0060.03612.38
5.4.150.0070.03712.38
5.4.140.0050.04112.06
5.4.130.0090.04212.05
5.4.120.0080.03412.00
5.4.110.0030.03712.00
5.4.100.0030.03612.00
5.4.90.0080.04112.00
5.4.80.0030.04712.00
5.4.70.0060.03412.00
5.4.60.0060.03512.00
5.4.50.0080.03712.00
5.4.40.0070.03711.99
5.4.30.0040.04111.98
5.4.20.0050.03711.98
5.4.10.0050.04111.98
5.4.00.0060.04911.48
5.3.290.0110.03512.80
5.3.280.0060.04112.71
5.3.270.0040.05112.72
5.3.260.0080.03612.71
5.3.250.0070.03912.71
5.3.240.0080.03612.72
5.3.230.0020.04012.71
5.3.220.0070.03712.68
5.3.210.0090.04412.68
5.3.200.0050.03812.68
5.3.190.0060.03612.68
5.3.180.0060.03612.67
5.3.170.0040.03712.67
5.3.160.0030.03912.67
5.3.150.0070.04112.68
5.3.140.0100.03612.66
5.3.130.0050.03912.66
5.3.120.0030.04112.66
5.3.110.0070.03612.66
5.3.100.0090.04012.12
5.3.90.0060.03912.09
5.3.80.0090.03512.07
5.3.70.0070.04112.08
5.3.60.0040.03812.07
5.3.50.0050.03512.00
5.3.40.0050.03612.00
5.3.30.0030.03811.95
5.3.20.0060.03411.73
5.3.10.0030.04211.70
5.3.00.0040.03811.68
5.2.170.0070.0309.18
5.2.160.0010.0329.19
5.2.150.0080.0339.19
5.2.140.0050.0299.18
5.2.130.0050.0279.14
5.2.120.0030.0299.14
5.2.110.0020.0329.15
5.2.100.0050.0319.14
5.2.90.0070.0309.14
5.2.80.0080.0269.14
5.2.70.0060.0319.14
5.2.60.0050.0319.09
5.2.50.0020.0339.06
5.2.40.0010.0339.04
5.2.30.0050.0409.02
5.2.20.0040.0349.00
5.2.10.0090.0288.92
5.2.00.0050.0328.79
5.1.60.0030.0258.07
5.1.50.0050.0238.07
5.1.40.0040.0298.05
5.1.30.0060.0238.40
5.1.20.0030.0278.42
5.1.10.0060.0278.14
5.1.00.0050.0288.14
5.0.50.0050.0296.63
5.0.40.0060.0186.48
5.0.30.0030.0326.30
5.0.20.0060.0176.26
5.0.10.0010.0216.24
5.0.00.0030.0306.23
4.4.90.0040.0144.77
4.4.80.0020.0164.76
4.4.70.0030.0154.76
4.4.60.0030.0154.75
4.4.50.0030.0154.77
4.4.40.0020.0294.71
4.4.30.0030.0154.76
4.4.20.0030.0154.84
4.4.10.0020.0164.85
4.4.00.0020.0254.76
4.3.110.0050.0154.67
4.3.100.0020.0154.66
4.3.90.0040.0134.63
4.3.80.0030.0244.59
4.3.70.0030.0144.63
4.3.60.0030.0154.63
4.3.50.0030.0164.63
4.3.40.0020.0254.54
4.3.30.0020.0223.28
4.3.20.0030.0153.26
4.3.10.0040.0213.22
4.3.00.0070.01315.89

preferences:
36.28 ms | 401 KiB | 5 Q