3v4l.org

run code in 500+ 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 = 13
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 13
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
filename:       /in/X3JQA
function name:  (null)
number of ops:  15
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, ->13
          2    > > FE_FETCH_R                                                   $4, !1, ->13
   11     3    >   FRAMELESS_ICALL_3                preg_replace        ~5      '%2F%5C%7B%28.%2A%3F%29%5C%7D%2F', '%28%3FP%3C%241%3E%5B%5Cw-%5D%2B%29'
          4        OP_DATA                                                      !1
          5        ASSIGN                                                       !2, ~5
   12     6        CONCAT                                               ~7      '%23%5E', !2
          7        CONCAT                                               ~8      ~7, '%24%23'
          8        ASSIGN                                                       !2, ~8
   13     9        INIT_FCALL                                                   'var_dump'
         10        SEND_VAR                                                     !2
         11        DO_ICALL                                                     
    9    12      > JMP                                                          ->2
         13    >   FE_FREE                                                      $4
   14    14      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
160.94 ms | 2111 KiB | 14 Q