3v4l.org

run code in 300+ PHP versions simultaneously
<?php $patterns = [ '/home', '/user', '/user/profile/{id}', '/user/{id}/edit', ]; foreach($patterns as $pattern) { $pattern_regex = preg_replace("/\{(.*?)\}/", "(?P<$1>[\w-]+)", $pattern); $pattern_regex = "#^" . $pattern_regex . "$#"; var_dump($pattern_regex); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 16
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 16
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
filename:       /in/X3JQA
function name:  (null)
number of ops:  18
compiled vars:  !0 = $patterns, !1 = $pattern, !2 = $pattern_regex
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
    9     1      > FE_RESET_R                                       $4      !0, ->16
          2    > > FE_FETCH_R                                               $4, !1, ->16
   11     3    >   INIT_FCALL                                               'preg_replace'
          4        SEND_VAL                                                 '%2F%5C%7B%28.%2A%3F%29%5C%7D%2F'
          5        SEND_VAL                                                 '%28%3FP%3C%241%3E%5B%5Cw-%5D%2B%29'
          6        SEND_VAR                                                 !1
          7        DO_ICALL                                         $5      
          8        ASSIGN                                                   !2, $5
   12     9        CONCAT                                           ~7      '%23%5E', !2
         10        CONCAT                                           ~8      ~7, '%24%23'
         11        ASSIGN                                                   !2, ~8
   13    12        INIT_FCALL                                               'var_dump'
         13        SEND_VAR                                                 !2
         14        DO_ICALL                                                 
    9    15      > JMP                                                      ->2
         16    >   FE_FREE                                                  $4
   14    17      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
214.55 ms | 940 KiB | 18 Q