3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr_postcode_regexes = [ '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.0070.01518.93
8.3.50.0090.01123.05
8.3.40.0120.00319.17
8.3.30.0070.00719.11
8.3.20.0000.00720.25
8.3.10.0000.00822.02
8.3.00.0060.00318.18
8.2.180.0120.00318.38
8.2.170.0070.00722.96
8.2.160.0070.00720.37
8.2.150.0050.00324.18
8.2.140.0000.00824.66
8.2.130.0030.00526.16
8.2.120.0080.00021.16
8.2.110.0040.00719.41
8.2.100.0030.00918.00
8.2.90.0050.00318.00
8.2.80.0040.00419.17
8.2.70.0050.00318.00
8.2.60.0000.00818.00
8.2.50.0030.00618.05
8.2.40.0040.00418.34
8.2.30.0080.00019.54
8.2.20.0030.00518.13
8.2.10.0080.00018.26
8.2.00.0000.00918.06
8.1.280.0110.00725.92
8.1.270.0030.00524.13
8.1.260.0040.00426.35
8.1.250.0000.01028.09
8.1.240.0060.00323.89
8.1.230.0030.00917.73
8.1.220.0000.00818.82
8.1.210.0000.00818.77
8.1.200.0000.00817.73
8.1.190.0000.00917.63
8.1.180.0070.00318.10
8.1.170.0000.00917.72
8.1.160.0000.00722.15
8.1.150.0000.00718.98
8.1.140.0080.00017.80
8.1.130.0040.00417.97
8.1.120.0050.00217.67
8.1.110.0050.00217.66
8.1.100.0080.00017.63
8.1.90.0100.00017.74
8.1.80.0090.00017.71
8.1.70.0040.00417.66
8.1.60.0060.00317.73
8.1.50.0030.00617.71
8.1.40.0040.00417.80
8.1.30.0030.00517.84
8.1.20.0000.00917.89
8.1.10.0000.00817.79
8.1.00.0080.00017.73
8.0.300.0000.00818.77
8.0.290.0000.00817.29
8.0.280.0000.00818.48
8.0.270.0000.00717.07
8.0.260.0000.00817.42
8.0.250.0000.00717.20
8.0.240.0090.00017.06
8.0.230.0040.00417.06
8.0.220.0040.00417.20
8.0.210.0030.00317.06
8.0.200.0000.00717.08
8.0.190.0000.00817.22
8.0.180.0040.00417.06
8.0.170.0030.00617.04
8.0.160.0070.00017.11
8.0.150.0040.00417.00
8.0.140.0040.00417.05
8.0.130.0040.00413.54
8.0.120.0040.00417.13
8.0.110.0080.00017.25
8.0.100.0080.00017.13
8.0.90.0040.00417.11
8.0.80.0070.01017.08
8.0.70.0080.00017.27
8.0.60.0080.00017.23
8.0.50.0040.00417.11
8.0.30.0160.00517.44
8.0.20.0090.01117.59
8.0.10.0000.00817.09
8.0.00.0180.00616.97
7.4.330.0000.00615.32
7.4.320.0000.00716.93
7.4.300.0030.00316.90
7.4.290.0030.00316.87
7.4.280.0040.00416.76
7.4.270.0000.00716.89
7.4.260.0000.00816.89
7.4.250.0030.00516.82
7.4.240.0020.00516.91
7.4.230.0000.00716.86
7.4.220.0100.01017.02
7.4.210.0040.01116.91
7.4.200.0000.00816.70
7.4.160.0090.00916.91
7.4.150.0100.01617.40
7.4.140.0070.01117.86
7.4.130.0080.01117.00
7.4.120.0110.01016.85
7.4.110.0140.00416.88
7.4.100.0120.00617.02
7.4.90.0110.00716.72
7.4.80.0060.01319.39
7.4.70.0070.01016.76
7.4.60.0120.00916.78
7.4.50.0000.00916.75
7.4.40.0090.00916.82
7.4.30.0130.00316.63
7.4.00.0070.01015.25
7.3.330.0030.00313.46
7.3.320.0060.00013.40
7.3.310.0050.00216.54
7.3.300.0040.00416.60
7.3.290.0000.01516.55
7.3.280.0080.01116.61
7.3.270.0090.00917.40
7.3.260.0080.01016.59
7.3.240.0120.00616.73
7.3.230.0070.01116.74
7.3.210.0190.00616.88
7.3.200.0160.00319.39
7.3.190.0120.00616.75
7.3.180.0130.00516.49
7.3.170.0090.00816.62
7.3.160.0130.00316.83
7.3.120.0040.00715.27
7.3.10.0030.01016.69
7.3.00.0070.01116.80
7.2.330.0080.01216.81
7.2.320.0070.01016.64
7.2.310.0180.00616.63
7.2.300.0060.01217.07
7.2.290.0140.00716.85
7.2.130.0070.00716.89
7.2.120.0190.00616.77
7.2.110.0100.00716.84
7.2.100.0070.00717.07
7.2.90.0100.01017.07
7.2.80.0200.00017.14
7.2.70.0070.00716.72
7.2.60.0080.00416.91
7.2.50.0100.00716.77
7.2.40.0150.00016.90
7.2.30.0100.00616.88
7.2.20.0000.01017.13
7.2.10.0060.00617.06
7.2.00.0060.01418.51
7.1.250.0180.00015.82
7.1.100.0140.01018.59
7.1.70.0030.00617.34
7.1.60.0100.01619.40
7.1.50.0110.01117.46
7.1.00.0030.08022.63
7.0.200.0070.00717.13
7.0.140.0100.07022.15
7.0.60.0000.04320.14
7.0.50.0130.05017.92
7.0.40.0070.06020.05
7.0.30.0530.06720.23
7.0.20.0270.05020.25
7.0.10.0030.04320.25
7.0.00.0030.04720.22
5.6.280.0000.10021.08
5.6.210.0100.07720.64
5.6.200.0070.03718.21
5.6.190.0130.03720.57
5.6.180.4070.05020.41
5.6.170.0330.04720.47
5.6.160.0030.04020.44
5.6.150.0100.03318.21
5.6.140.0130.07318.25
5.6.130.0100.08318.21
5.6.120.0000.04720.96
5.6.110.0070.08321.06
5.6.100.0000.08320.99
5.6.90.0130.03321.00
5.6.80.0030.04720.55
5.6.70.4470.04320.52
5.5.350.0230.07720.54
5.5.340.0070.06317.96
5.5.330.0100.08720.19
5.5.320.3130.04720.24
5.5.310.0230.05320.21
5.5.300.0100.05017.89
5.5.290.0070.06317.92
5.5.280.0070.08320.70
5.5.270.0030.04020.91
5.5.260.0170.07020.97
5.5.250.0130.07020.71
5.5.240.0200.06720.29
5.4.450.0370.04319.26
5.4.440.0370.05019.11
5.4.430.0430.04719.13
5.4.420.0570.04719.48
5.4.410.0170.03319.26
5.4.400.0530.03718.78
5.4.390.0370.03719.10
5.4.380.0400.07018.70
5.4.370.0300.05018.60
5.4.360.0370.05718.78
5.4.350.0370.06318.50
5.4.340.0600.08718.50
5.4.320.0060.03612.49
5.4.310.0100.04212.48
5.4.300.0050.04112.49
5.4.290.0050.04912.49
5.4.280.0070.03812.38
5.4.270.0050.03912.38
5.4.260.0050.04412.39
5.4.250.0050.03912.39
5.4.240.0060.03712.39
5.4.230.0060.03912.38
5.4.220.0070.03612.38
5.4.210.0060.03712.38
5.4.200.0100.03412.38
5.4.190.0060.04512.38
5.4.180.0050.05212.38
5.4.170.0100.04112.39
5.4.160.0080.03412.38
5.4.150.0060.04012.38
5.4.140.0080.03512.06
5.4.130.0110.03012.05
5.4.120.0090.03412.00
5.4.110.0070.03612.00
5.4.100.0070.04612.00
5.4.90.0070.03712.00
5.4.80.0070.03712.00
5.4.70.0080.03312.00
5.4.60.0070.03311.99
5.4.50.0110.03011.99
5.4.40.0030.03711.98
5.4.30.0070.03911.98
5.4.20.0080.03411.98
5.4.10.0060.03411.98
5.4.00.0050.03711.47
5.3.290.0040.04112.80
5.3.280.0060.03712.71
5.3.270.0070.03712.72
5.3.260.0060.03912.72
5.3.250.0040.03812.72
5.3.240.0090.03312.72
5.3.230.0060.03712.70
5.3.220.0040.04012.68
5.3.210.0070.03912.68
5.3.200.0090.03512.68
5.3.190.0030.03912.68
5.3.180.0100.03512.67
5.3.170.0070.03912.67
5.3.160.0080.03412.67
5.3.150.0040.03812.67
5.3.140.0070.03512.66
5.3.130.0050.03912.66
5.3.120.0090.05012.65
5.3.110.0050.04112.66
5.3.100.0060.03712.12
5.3.90.0060.03612.08
5.3.80.0040.04112.07
5.3.70.0070.03512.07
5.3.60.0060.03512.07
5.3.50.0030.03912.00
5.3.40.0080.04112.00
5.3.30.0050.04111.95
5.3.20.0080.03811.73
5.3.10.0080.03611.70
5.3.00.0060.03511.68
5.2.170.0080.0269.18
5.2.160.0060.0279.19
5.2.150.0030.0309.18
5.2.140.0060.0359.18
5.2.130.0050.0299.14
5.2.120.0090.0309.14
5.2.110.0040.0329.15
5.2.100.0050.0279.14
5.2.90.0080.0249.14
5.2.80.0100.0339.14
5.2.70.0050.0389.14
5.2.60.0100.0289.09
5.2.50.0040.0309.06
5.2.40.0080.0329.03
5.2.30.0090.0259.01
5.2.20.0040.0289.00
5.2.10.0060.0278.93
5.2.00.0020.0308.78
5.1.60.0050.0278.07
5.1.50.0050.0278.07
5.1.40.0040.0248.05
5.1.30.0050.0258.39
5.1.20.0040.0268.42
5.1.10.0060.0238.14
5.1.00.0020.0278.14
5.0.50.0020.0226.63
5.0.40.0030.0196.48
5.0.30.0050.0306.29
5.0.20.0040.0186.26
5.0.10.0010.0226.24
5.0.00.0030.0296.23
4.4.90.0040.0134.78
4.4.80.0030.0154.75
4.4.70.0040.0194.75
4.4.60.0010.0174.76
4.4.50.0050.0144.77
4.4.40.0010.0304.71
4.4.30.0060.0144.76
4.4.20.0010.0174.84
4.4.10.0030.0164.85
4.4.00.0030.0304.76
4.3.110.0040.0204.67
4.3.100.0040.0134.66
4.3.90.0020.0154.64
4.3.80.0030.0244.59
4.3.70.0020.0154.63
4.3.60.0020.0154.63
4.3.50.0040.0144.63
4.3.40.0050.0294.54
4.3.30.0010.0173.28
4.3.20.0000.0183.26
4.3.10.0030.0163.22
4.3.00.0030.01715.89

preferences:
36.37 ms | 401 KiB | 5 Q