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, '') === 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 = 28
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 28
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 17
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 17
Branch analysis from position: 28
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 28
filename:       /in/Nof0j
function name:  (null)
number of ops:  33
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, ->28
          4    > > FE_FETCH_R                                                   $8, !3, ->28
   17     5    >   BEGIN_SILENCE                                        ~9      
          6        FRAMELESS_ICALL_2                preg_match          ~10     !3, ''
          7        END_SILENCE                                                  ~9
          8        TYPE_CHECK                                        4          ~10
          9      > JMPZ                                                         ~11, ->17
   19    10    >   INIT_FCALL                                                   'preg_quote'
         11        SEND_VAR                                                     !3
         12        SEND_VAL                                                     '%2F'
         13        DO_ICALL                                             $12     
         14        CONCAT                                               ~13     '%2F', $12
         15        CONCAT                                               ~14     ~13, '%2F'
         16        ASSIGN                                                       !3, ~14
   21    17    >   INIT_FCALL                                                   'preg_match'
         18        SEND_VAR                                                     !3
         19        SEND_VAR                                                     !1
         20        SEND_REF                                                     !4
         21        DO_ICALL                                                     
   22    22        FETCH_DIM_IS                                         ~18     !4, 0
         23        COALESCE                                             ~19     ~18
         24        QM_ASSIGN                                            ~19     null
         25        ASSIGN_DIM                                                   !2, !3
         26        OP_DATA                                                      ~19
   16    27      > JMP                                                          ->4
         28    >   FE_FREE                                                      $8
   24    29        INIT_FCALL                                                   'var_export'
         30        SEND_VAR                                                     !2
         31        DO_ICALL                                                     
         32      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
158.13 ms | 1744 KiB | 16 Q