3v4l.org

run code in 300+ 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, '') === false) { // not a regex, make into one $v = '/' . preg_quote($v, '/') . '/'; } preg_match($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 = 13, Position 2 = 20
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 20
Branch analysis from position: 31
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 31
filename:       /in/Nof0j
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_VAL                                                 ''
          9        DO_ICALL                                         $10     
         10        END_SILENCE                                              ~9
         11        TYPE_CHECK                                    4          $10
         12      > JMPZ                                                     ~11, ->20
   19    13    >   INIT_FCALL                                               'preg_quote'
         14        SEND_VAR                                                 !3
         15        SEND_VAL                                                 '%2F'
         16        DO_ICALL                                         $12     
         17        CONCAT                                           ~13     '%2F', $12
         18        CONCAT                                           ~14     ~13, '%2F'
         19        ASSIGN                                                   !3, ~14
   21    20    >   INIT_FCALL                                               'preg_match'
         21        SEND_VAR                                                 !3
         22        SEND_VAR                                                 !1
         23        SEND_REF                                                 !4
         24        DO_ICALL                                                 
   22    25        FETCH_DIM_IS                                     ~18     !4, 0
         26        COALESCE                                         ~19     ~18
         27        QM_ASSIGN                                        ~19     null
         28        ASSIGN_DIM                                               !2, !3
         29        OP_DATA                                                  ~19
   16    30      > JMP                                                      ->4
         31    >   FE_FREE                                                  $8
   24    32        INIT_FCALL                                               'var_export'
         33        SEND_VAR                                                 !2
         34        DO_ICALL                                                 
         35      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
146.43 ms | 1079 KiB | 16 Q