3v4l.org

run code in 500+ PHP versions simultaneously
<?PHP $list = [ // an array list of string/regex that i want to check "lorem ipsum", // a words "example", // another word "/(nulla)/", // a valid regex "/[,.]/", // a valid regex "^dolor^", // a valid regex "/path/to/dir/", // not a valid regex "[integer]i", // valid regex not implementing a character class ]; $input_string = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer quam ex, vestibulum sed laoreet auctor, iaculis eget velit. Donec mattis, /path/to/dir/ nulla ac suscipit maximus, leo metus vestibulum eros, nec finibus nisl dui ut est. Nam tristique varius mauris, a faucibus augue."; $result = []; foreach($list as $v) { if (@preg_match($v, $input_string, $m) === false) { preg_match('/' . preg_quote($v, '/') . '/', $input_string, $m); } $result[$v] = $m[0] ?? null; } var_export($result);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 31
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 31
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 25
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 25
Branch analysis from position: 31
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 31
filename:       /in/FtWhH
function name:  (null)
number of ops:  36
compiled vars:  !0 = $list, !1 = $input_string, !2 = $result, !3 = $v, !4 = $m
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
   13     1        ASSIGN                                                       !1, 'Lorem+ipsum+dolor+sit+amet%2C+consectetur+adipiscing+elit.+Integer+quam+ex%2C+vestibulum+sed+laoreet+auctor%2C+iaculis+eget+velit.+Donec+mattis%2C+%2Fpath%2Fto%2Fdir%2F+nulla+ac+suscipit+maximus%2C+leo++metus+vestibulum+eros%2C+nec+finibus+nisl+dui+ut+est.+Nam+tristique+varius+mauris%2C+a+faucibus+augue.'
   15     2        ASSIGN                                                       !2, <array>
   16     3      > FE_RESET_R                                           $8      !0, ->31
          4    > > FE_FETCH_R                                                   $8, !3, ->31
   17     5    >   BEGIN_SILENCE                                        ~9      
          6        INIT_FCALL                                                   'preg_match'
          7        SEND_VAR                                                     !3
          8        SEND_VAR                                                     !1
          9        SEND_REF                                                     !4
         10        DO_ICALL                                             $10     
         11        END_SILENCE                                                  ~9
         12        TYPE_CHECK                                        4          $10
         13      > JMPZ                                                         ~11, ->25
   18    14    >   INIT_FCALL                                                   'preg_match'
         15        INIT_FCALL                                                   'preg_quote'
         16        SEND_VAR                                                     !3
         17        SEND_VAL                                                     '%2F'
         18        DO_ICALL                                             $12     
         19        CONCAT                                               ~13     '%2F', $12
         20        CONCAT                                               ~14     ~13, '%2F'
         21        SEND_VAL                                                     ~14
         22        SEND_VAR                                                     !1
         23        SEND_REF                                                     !4
         24        DO_ICALL                                                     
   20    25    >   FETCH_DIM_IS                                         ~17     !4, 0
         26        COALESCE                                             ~18     ~17
         27        QM_ASSIGN                                            ~18     null
         28        ASSIGN_DIM                                                   !2, !3
         29        OP_DATA                                                      ~18
   16    30      > JMP                                                          ->4
         31    >   FE_FREE                                                      $8
   22    32        INIT_FCALL                                                   'var_export'
         33        SEND_VAR                                                     !2
         34        DO_ICALL                                                     
         35      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
167.56 ms | 1744 KiB | 16 Q