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*$'; } var_dump($arr_postcode_regexes);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 25
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 25
Branch analysis from position: 3
2 jumps found. (Code = 77) Position 1 = 6, Position 2 = 15
Branch analysis from position: 6
2 jumps found. (Code = 78) Position 1 = 7, Position 2 = 15
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 15
Branch analysis from position: 25
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 25
filename:       /in/urL1v
function name:  (null)
number of ops:  30
compiled vars:  !0 = $arr_postcode_regexes, !1 = $arr_parts, !2 = $str_id, !3 = $arr_temp, !4 = $arr_part
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   30     1      > FE_RESET_R                                       $6      !0, ->25
          2    > > FE_FETCH_R                                       ~7      $6, !1, ->25
          3    >   ASSIGN                                                   !2, ~7
   31     4        ASSIGN                                                   !3, <array>
   33     5      > FE_RESET_R                                       $10     !1, ->15
          6    > > FE_FETCH_R                                               $10, !4, ->15
   34     7    >   INIT_FCALL                                               'implode'
          8        SEND_VAL                                                 '%5Cs%2A'
          9        SEND_VAR                                                 !4
         10        DO_ICALL                                         $12     
         11        CONCAT                                           ~13     $12, '%5Cs%2A%5B0-9%5D%5Cs%2A%5BA-Z%5D%5Cs%2A%5BA-Z%5D'
         12        ASSIGN_DIM                                               !3
         13        OP_DATA                                                  ~13
   33    14      > JMP                                                      ->6
         15    >   FE_FREE                                                  $10
   37    16        INIT_FCALL                                               'implode'
         17        SEND_VAL                                                 '%7C'
         18        SEND_VAR                                                 !3
         19        DO_ICALL                                         $15     
         20        CONCAT                                           ~16     '%5E%5Cs%2A%28', $15
         21        CONCAT                                           ~17     ~16, '%29%5Cs%2A%24'
         22        ASSIGN_DIM                                               !0, !2
         23        OP_DATA                                                  ~17
   30    24      > JMP                                                      ->2
         25    >   FE_FREE                                                  $6
   40    26        INIT_FCALL                                               'var_dump'
         27        SEND_VAR                                                 !0
         28        DO_ICALL                                                 
         29      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.89 ms | 1388 KiB | 17 Q