3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string = 'My nAmE ïs Tom.'; // case-sensitive matching, including partial matching $array = ['foo', 'nAmE']; $regex[] = '/' . implode('|', array_map(fn($v) => preg_quote($v, '/'), $array)) . '/'; // case-insensitive matching, including partial matching $array = ['foo', 'om']; $regex[] = '/' . implode('|', array_map(fn($v) => preg_quote($v, '/'), $array)) . '/i'; // case-insensitive matching, full word matching only $array = ['foo', 'tom']; $regex[] = '/\b(?:' . implode('|', array_map(fn($v) => preg_quote($v, '/'), $array)) . ')\b/i'; // case-insensitive matching, full word matching only, multibyte aware $array = ['foo', 'ïs']; $regex[] = '/\b(?:' . implode('|', array_map(fn($v) => preg_quote($v, '/'), $array)) . ')\b/iu'; foreach ($regex as $r) { if (preg_match($r, $string, $m)) { echo "found '$m[0]' using $r on $string\n"; } else { echo "no match using $r on $string\n"; } }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 58, Position 2 = 82
Branch analysis from position: 58
2 jumps found. (Code = 78) Position 1 = 59, Position 2 = 82
Branch analysis from position: 59
2 jumps found. (Code = 43) Position 1 = 65, Position 2 = 75
Branch analysis from position: 65
1 jumps found. (Code = 42) Position 1 = 81
Branch analysis from position: 81
1 jumps found. (Code = 42) Position 1 = 58
Branch analysis from position: 58
Branch analysis from position: 75
1 jumps found. (Code = 42) Position 1 = 58
Branch analysis from position: 58
Branch analysis from position: 82
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 82
filename:       /in/9q1FF
function name:  (null)
number of ops:  84
compiled vars:  !0 = $string, !1 = $array, !2 = $regex, !3 = $r, !4 = $m
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 'My+nAmE+%C3%AFs+Tom.'
    6     1        ASSIGN                                                   !1, <array>
    7     2        INIT_FCALL                                               'implode'
          3        SEND_VAL                                                 '%7C'
          4        INIT_FCALL                                               'array_map'
          5        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F9q1FF%3A7%240'
          6        SEND_VAL                                                 ~8
          7        SEND_VAR                                                 !1
          8        DO_ICALL                                         $9      
          9        SEND_VAR                                                 $9
         10        DO_ICALL                                         $10     
         11        CONCAT                                           ~11     '%2F', $10
         12        CONCAT                                           ~12     ~11, '%2F'
         13        ASSIGN_DIM                                               !2
         14        OP_DATA                                                  ~12
   11    15        ASSIGN                                                   !1, <array>
   12    16        INIT_FCALL                                               'implode'
         17        SEND_VAL                                                 '%7C'
         18        INIT_FCALL                                               'array_map'
         19        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F9q1FF%3A12%241'
         20        SEND_VAL                                                 ~15
         21        SEND_VAR                                                 !1
         22        DO_ICALL                                         $16     
         23        SEND_VAR                                                 $16
         24        DO_ICALL                                         $17     
         25        CONCAT                                           ~18     '%2F', $17
         26        CONCAT                                           ~19     ~18, '%2Fi'
         27        ASSIGN_DIM                                               !2
         28        OP_DATA                                                  ~19
   15    29        ASSIGN                                                   !1, <array>
   16    30        INIT_FCALL                                               'implode'
         31        SEND_VAL                                                 '%7C'
         32        INIT_FCALL                                               'array_map'
         33        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F9q1FF%3A16%242'
         34        SEND_VAL                                                 ~22
         35        SEND_VAR                                                 !1
         36        DO_ICALL                                         $23     
         37        SEND_VAR                                                 $23
         38        DO_ICALL                                         $24     
         39        CONCAT                                           ~25     '%2F%5Cb%28%3F%3A', $24
         40        CONCAT                                           ~26     ~25, '%29%5Cb%2Fi'
         41        ASSIGN_DIM                                               !2
         42        OP_DATA                                                  ~26
   19    43        ASSIGN                                                   !1, <array>
   20    44        INIT_FCALL                                               'implode'
         45        SEND_VAL                                                 '%7C'
         46        INIT_FCALL                                               'array_map'
         47        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F9q1FF%3A20%243'
         48        SEND_VAL                                                 ~29
         49        SEND_VAR                                                 !1
         50        DO_ICALL                                         $30     
         51        SEND_VAR                                                 $30
         52        DO_ICALL                                         $31     
         53        CONCAT                                           ~32     '%2F%5Cb%28%3F%3A', $31
         54        CONCAT                                           ~33     ~32, '%29%5Cb%2Fiu'
         55        ASSIGN_DIM                                               !2
         56        OP_DATA                                                  ~33
   23    57      > FE_RESET_R                                       $34     !2, ->82
         58    > > FE_FETCH_R                                               $34, !3, ->82
   24    59    >   INIT_FCALL                                               'preg_match'
         60        SEND_VAR                                                 !3
         61        SEND_VAR                                                 !0
         62        SEND_REF                                                 !4
         63        DO_ICALL                                         $35     
         64      > JMPZ                                                     $35, ->75
   25    65    >   ROPE_INIT                                     7  ~38     'found+%27'
         66        FETCH_DIM_R                                      ~36     !4, 0
         67        ROPE_ADD                                      1  ~38     ~38, ~36
         68        ROPE_ADD                                      2  ~38     ~38, '%27+using+'
         69        ROPE_ADD                                      3  ~38     ~38, !3
         70        ROPE_ADD                                      4  ~38     ~38, '+on+'
         71        ROPE_ADD                                      5  ~38     ~38, !0
         72        ROPE_END                                      6  ~37     ~38, '%0A'
         73        ECHO                                                     ~37
         74      > JMP                                                      ->81
   27    75    >   ROPE_INIT                                     5  ~43     'no+match+using+'
         76        ROPE_ADD                                      1  ~43     ~43, !3
         77        ROPE_ADD                                      2  ~43     ~43, '+on+'
         78        ROPE_ADD                                      3  ~43     ~43, !0
         79        ROPE_END                                      4  ~42     ~43, '%0A'
         80        ECHO                                                     ~42
   23    81    > > JMP                                                      ->58
         82    >   FE_FREE                                                  $34
   29    83      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2F9q1FF%3A7%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9q1FF
function name:  {closure}
number of ops:  7
compiled vars:  !0 = $v
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
          1        INIT_FCALL                                               'preg_quote'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 '%2F'
          4        DO_ICALL                                         $1      
          5      > RETURN                                                   $1
          6*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2F9q1FF%3A7%240

Function %00%7Bclosure%7D%2Fin%2F9q1FF%3A12%241:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9q1FF
function name:  {closure}
number of ops:  7
compiled vars:  !0 = $v
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
          1        INIT_FCALL                                               'preg_quote'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 '%2F'
          4        DO_ICALL                                         $1      
          5      > RETURN                                                   $1
          6*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2F9q1FF%3A12%241

Function %00%7Bclosure%7D%2Fin%2F9q1FF%3A16%242:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9q1FF
function name:  {closure}
number of ops:  7
compiled vars:  !0 = $v
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   RECV                                             !0      
          1        INIT_FCALL                                               'preg_quote'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 '%2F'
          4        DO_ICALL                                         $1      
          5      > RETURN                                                   $1
          6*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2F9q1FF%3A16%242

Function %00%7Bclosure%7D%2Fin%2F9q1FF%3A20%243:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9q1FF
function name:  {closure}
number of ops:  7
compiled vars:  !0 = $v
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   RECV                                             !0      
          1        INIT_FCALL                                               'preg_quote'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 '%2F'
          4        DO_ICALL                                         $1      
          5      > RETURN                                                   $1
          6*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2F9q1FF%3A20%243

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
168.66 ms | 1419 KiB | 21 Q