3v4l.org

run code in 300+ PHP versions simultaneously
<?php $words = array("man", "map", "php", "pop", "pnp"); $patterns = array("ma?", "p?p"); foreach ($patterns as $pattern) { $regex = '\b(' . str_replace('?', '.', $pattern) . ')\b'; $count = preg_match_all("/$regex/", implode('-', $words), $matches); echo "$pattern matched $count times on " . implode(',', $matches[1]) . ".\n"; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 38
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 38
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 38
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 38
filename:       /in/e4GbA
function name:  (null)
number of ops:  40
compiled vars:  !0 = $words, !1 = $patterns, !2 = $pattern, !3 = $regex, !4 = $count, !5 = $matches
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    4     1        ASSIGN                                                   !1, <array>
    5     2      > FE_RESET_R                                       $8      !1, ->38
          3    > > FE_FETCH_R                                               $8, !2, ->38
    6     4    >   INIT_FCALL                                               'str_replace'
          5        SEND_VAL                                                 '%3F'
          6        SEND_VAL                                                 '.'
          7        SEND_VAR                                                 !2
          8        DO_ICALL                                         $9      
          9        CONCAT                                           ~10     '%5Cb%28', $9
         10        CONCAT                                           ~11     ~10, '%29%5Cb'
         11        ASSIGN                                                   !3, ~11
    7    12        INIT_FCALL                                               'preg_match_all'
         13        ROPE_INIT                                     3  ~14     '%2F'
         14        ROPE_ADD                                      1  ~14     ~14, !3
         15        ROPE_END                                      2  ~13     ~14, '%2F'
         16        SEND_VAL                                                 ~13
         17        INIT_FCALL                                               'implode'
         18        SEND_VAL                                                 '-'
         19        SEND_VAR                                                 !0
         20        DO_ICALL                                         $16     
         21        SEND_VAR                                                 $16
         22        SEND_REF                                                 !5
         23        DO_ICALL                                         $17     
         24        ASSIGN                                                   !4, $17
    8    25        ROPE_INIT                                     4  ~20     !2
         26        ROPE_ADD                                      1  ~20     ~20, '+matched+'
         27        ROPE_ADD                                      2  ~20     ~20, !4
         28        ROPE_END                                      3  ~19     ~20, '+times+on+'
         29        INIT_FCALL                                               'implode'
         30        SEND_VAL                                                 '%2C'
         31        FETCH_DIM_R                                      ~22     !5, 1
         32        SEND_VAL                                                 ~22
         33        DO_ICALL                                         $23     
         34        CONCAT                                           ~24     ~19, $23
         35        CONCAT                                           ~25     ~24, '.%0A'
         36        ECHO                                                     ~25
    5    37      > JMP                                                      ->3
         38    >   FE_FREE                                                  $8
    9    39      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
174.11 ms | 1400 KiB | 19 Q