3v4l.org

run code in 300+ PHP versions simultaneously
<?php $input = 'S1G6AB'; // given this $store = '5I6GAB'; // actually this $regex = implode('', array_map(function ($c) { $map = ['S'=>'[S5]','5'=>'[S5]','1'=>'[1I]','I'=>'[1I]','G'=>'[6G]','6'=>'[6G]']; return (array_key_exists($c, $map) ? $map[$c] : $c); }, str_split($input))); /* $regex = implode('', array_map( function ($char) { echo $char; return $char; static $map = ['S'=>'[S5]','5'=>'[S5]','1'=>'[1I]','I'=>'[1I]','G'=>'[6G]','6'=>'[6G]']; return array_key_exists($char, $map) ? $map[$char] : $char; }. [ 'a', 'b' ] // str_split($input) )); */ var_dump($regex); echo $regex . PHP_EOL; echo (0 < preg_match("/$regex/", $store) ? 'Match' : 'No match');
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 29, Position 2 = 31
Branch analysis from position: 29
1 jumps found. (Code = 42) Position 1 = 32
Branch analysis from position: 32
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 31
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Tj5Rh
function name:  (null)
number of ops:  34
compiled vars:  !0 = $input, !1 = $store, !2 = $regex
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, 'S1G6AB'
    3     1        ASSIGN                                                   !1, '5I6GAB'
    5     2        INIT_FCALL                                               'implode'
          3        SEND_VAL                                                 ''
          4        INIT_FCALL                                               'array_map'
          5        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FTj5Rh%3A5%240'
    8     6        SEND_VAL                                                 ~5
          7        INIT_FCALL                                               'str_split'
          8        SEND_VAR                                                 !0
          9        DO_ICALL                                         $6      
         10        SEND_VAR                                                 $6
         11        DO_ICALL                                         $7      
         12        SEND_VAR                                                 $7
         13        DO_ICALL                                         $8      
    5    14        ASSIGN                                                   !2, $8
   20    15        INIT_FCALL                                               'var_dump'
         16        SEND_VAR                                                 !2
         17        DO_ICALL                                                 
   21    18        CONCAT                                           ~11     !2, '%0A'
         19        ECHO                                                     ~11
   22    20        INIT_FCALL                                               'preg_match'
         21        ROPE_INIT                                     3  ~13     '%2F'
         22        ROPE_ADD                                      1  ~13     ~13, !2
         23        ROPE_END                                      2  ~12     ~13, '%2F'
         24        SEND_VAL                                                 ~12
         25        SEND_VAR                                                 !1
         26        DO_ICALL                                         $15     
         27        IS_SMALLER                                               0, $15
         28      > JMPZ                                                     ~16, ->31
         29    >   QM_ASSIGN                                        ~17     'Match'
         30      > JMP                                                      ->32
         31    >   QM_ASSIGN                                        ~17     'No+match'
         32    >   ECHO                                                     ~17
         33      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FTj5Rh%3A5%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 7
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Tj5Rh
function name:  {closure}
number of ops:  10
compiled vars:  !0 = $c, !1 = $map
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
    6     1        ASSIGN                                                   !1, <array>
    7     2        ARRAY_KEY_EXISTS                                         !0, !1
          3      > JMPZ                                                     ~3, ->7
          4    >   FETCH_DIM_R                                      ~4      !1, !0
          5        QM_ASSIGN                                        ~5      ~4
          6      > JMP                                                      ->8
          7    >   QM_ASSIGN                                        ~5      !0
          8    > > RETURN                                                   ~5
    8     9*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FTj5Rh%3A5%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.76 ms | 1400 KiB | 23 Q