3v4l.org

run code in 500+ 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 = 46, Position 2 = 70
Branch analysis from position: 46
2 jumps found. (Code = 78) Position 1 = 47, Position 2 = 70
Branch analysis from position: 47
2 jumps found. (Code = 43) Position 1 = 53, Position 2 = 63
Branch analysis from position: 53
1 jumps found. (Code = 42) Position 1 = 69
Branch analysis from position: 69
1 jumps found. (Code = 42) Position 1 = 46
Branch analysis from position: 46
Branch analysis from position: 63
1 jumps found. (Code = 42) Position 1 = 46
Branch analysis from position: 46
Branch analysis from position: 70
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 70
filename:       /in/9q1FF
function name:  (null)
number of ops:  72
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                                                   'array_map'
          3        DECLARE_LAMBDA_FUNCTION                              ~8      [0]
          4        SEND_VAL                                                     ~8
          5        SEND_VAR                                                     !1
          6        DO_ICALL                                             $9      
          7        FRAMELESS_ICALL_2                implode             ~10     '%7C', $9
          8        CONCAT                                               ~11     '%2F', ~10
          9        CONCAT                                               ~12     ~11, '%2F'
         10        ASSIGN_DIM                                                   !2
         11        OP_DATA                                                      ~12
   11    12        ASSIGN                                                       !1, <array>
   12    13        INIT_FCALL                                                   'array_map'
         14        DECLARE_LAMBDA_FUNCTION                              ~15     [1]
         15        SEND_VAL                                                     ~15
         16        SEND_VAR                                                     !1
         17        DO_ICALL                                             $16     
         18        FRAMELESS_ICALL_2                implode             ~17     '%7C', $16
         19        CONCAT                                               ~18     '%2F', ~17
         20        CONCAT                                               ~19     ~18, '%2Fi'
         21        ASSIGN_DIM                                                   !2
         22        OP_DATA                                                      ~19
   15    23        ASSIGN                                                       !1, <array>
   16    24        INIT_FCALL                                                   'array_map'
         25        DECLARE_LAMBDA_FUNCTION                              ~22     [2]
         26        SEND_VAL                                                     ~22
         27        SEND_VAR                                                     !1
         28        DO_ICALL                                             $23     
         29        FRAMELESS_ICALL_2                implode             ~24     '%7C', $23
         30        CONCAT                                               ~25     '%2F%5Cb%28%3F%3A', ~24
         31        CONCAT                                               ~26     ~25, '%29%5Cb%2Fi'
         32        ASSIGN_DIM                                                   !2
         33        OP_DATA                                                      ~26
   19    34        ASSIGN                                                       !1, <array>
   20    35        INIT_FCALL                                                   'array_map'
         36        DECLARE_LAMBDA_FUNCTION                              ~29     [3]
         37        SEND_VAL                                                     ~29
         38        SEND_VAR                                                     !1
         39        DO_ICALL                                             $30     
         40        FRAMELESS_ICALL_2                implode             ~31     '%7C', $30
         41        CONCAT                                               ~32     '%2F%5Cb%28%3F%3A', ~31
         42        CONCAT                                               ~33     ~32, '%29%5Cb%2Fiu'
         43        ASSIGN_DIM                                                   !2
         44        OP_DATA                                                      ~33
   23    45      > FE_RESET_R                                           $34     !2, ->70
         46    > > FE_FETCH_R                                                   $34, !3, ->70
   24    47    >   INIT_FCALL                                                   'preg_match'
         48        SEND_VAR                                                     !3
         49        SEND_VAR                                                     !0
         50        SEND_REF                                                     !4
         51        DO_ICALL                                             $35     
         52      > JMPZ                                                         $35, ->63
   25    53    >   ROPE_INIT                                         7  ~38     'found+%27'
         54        FETCH_DIM_R                                          ~36     !4, 0
         55        ROPE_ADD                                          1  ~38     ~38, ~36
         56        ROPE_ADD                                          2  ~38     ~38, '%27+using+'
         57        ROPE_ADD                                          3  ~38     ~38, !3
         58        ROPE_ADD                                          4  ~38     ~38, '+on+'
         59        ROPE_ADD                                          5  ~38     ~38, !0
         60        ROPE_END                                          6  ~37     ~38, '%0A'
         61        ECHO                                                         ~37
   24    62      > JMP                                                          ->69
   27    63    >   ROPE_INIT                                         5  ~43     'no+match+using+'
         64        ROPE_ADD                                          1  ~43     ~43, !3
         65        ROPE_ADD                                          2  ~43     ~43, '+on+'
         66        ROPE_ADD                                          3  ~43     ~43, !0
         67        ROPE_END                                          4  ~42     ~43, '%0A'
         68        ECHO                                                         ~42
   23    69    > > JMP                                                          ->46
         70    >   FE_FREE                                                      $34
   29    71      > RETURN                                                       1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9q1FF
function name:  {closure:/in/9q1FF:7}
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 Dynamic Function 0

Dynamic Function 1
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9q1FF
function name:  {closure:/in/9q1FF:12}
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 Dynamic Function 1

Dynamic Function 2
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9q1FF
function name:  {closure:/in/9q1FF:16}
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 Dynamic Function 2

Dynamic Function 3
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9q1FF
function name:  {closure:/in/9q1FF:20}
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 Dynamic Function 3

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
161.97 ms | 1918 KiB | 17 Q