3v4l.org

run code in 300+ PHP versions simultaneously
<?php // Everything you enter here will be executed by our servers. Try it! $wildcard = '*'; $urlParts = array( 'path' => 'example.com/sub/path/wildcard/*' ); $patternParts = explode($wildcard, $urlParts['path']); foreach ($patternParts as &$pPart) { $pPart = preg_quote($pPart, '/'); } unset($pPart); var_dump($patternParts); //Случай, когда * находится в конце строки - возможны любые вложенные пути if ($patternParts[count($patternParts)-1] == '') { array_pop($patternParts); if (count($patternParts) > 1) { $pattern = implode('\w+', $patternParts); } else { $pattern = $patternParts[0]; } $pattern.= '[\w\/]+'; } else { $pattern = implode('\w+', $patternParts); } $pattern = '/^' . $pattern . '$/im'; var_dump($pattern);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 125) Position 1 = 9, Position 2 = 16
Branch analysis from position: 9
2 jumps found. (Code = 126) Position 1 = 10, Position 2 = 16
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 16
2 jumps found. (Code = 43) Position 1 = 26, Position 2 = 42
Branch analysis from position: 26
2 jumps found. (Code = 43) Position 1 = 32, Position 2 = 38
Branch analysis from position: 32
1 jumps found. (Code = 42) Position 1 = 40
Branch analysis from position: 40
1 jumps found. (Code = 42) Position 1 = 47
Branch analysis from position: 47
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 38
1 jumps found. (Code = 42) Position 1 = 47
Branch analysis from position: 47
Branch analysis from position: 42
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
filename:       /in/v30T0
function name:  (null)
number of ops:  54
compiled vars:  !0 = $wildcard, !1 = $urlParts, !2 = $patternParts, !3 = $pPart, !4 = $pattern
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   ASSIGN                                                   !0, '%2A'
    5     1        ASSIGN                                                   !1, <array>
   10     2        INIT_FCALL                                               'explode'
          3        SEND_VAR                                                 !0
          4        FETCH_DIM_R                                      ~7      !1, 'path'
          5        SEND_VAL                                                 ~7
          6        DO_ICALL                                         $8      
          7        ASSIGN                                                   !2, $8
   11     8      > FE_RESET_RW                                      $10     !2, ->16
          9    > > FE_FETCH_RW                                              $10, !3, ->16
   12    10    >   INIT_FCALL                                               'preg_quote'
         11        SEND_VAR                                                 !3
         12        SEND_VAL                                                 '%2F'
         13        DO_ICALL                                         $11     
         14        ASSIGN                                                   !3, $11
   11    15      > JMP                                                      ->9
         16    >   FE_FREE                                                  $10
   14    17        UNSET_CV                                                 !3
   16    18        INIT_FCALL                                               'var_dump'
         19        SEND_VAR                                                 !2
         20        DO_ICALL                                                 
   19    21        COUNT                                            ~14     !2
         22        SUB                                              ~15     ~14, 1
         23        FETCH_DIM_R                                      ~16     !2, ~15
         24        IS_EQUAL                                                 ~16, ''
         25      > JMPZ                                                     ~17, ->42
   20    26    >   INIT_FCALL                                               'array_pop'
         27        SEND_REF                                                 !2
         28        DO_ICALL                                                 
   22    29        COUNT                                            ~19     !2
         30        IS_SMALLER                                               1, ~19
         31      > JMPZ                                                     ~20, ->38
   23    32    >   INIT_FCALL                                               'implode'
         33        SEND_VAL                                                 '%5Cw%2B'
         34        SEND_VAR                                                 !2
         35        DO_ICALL                                         $21     
         36        ASSIGN                                                   !4, $21
         37      > JMP                                                      ->40
   26    38    >   FETCH_DIM_R                                      ~23     !2, 0
         39        ASSIGN                                                   !4, ~23
   29    40    >   ASSIGN_OP                                     8          !4, '%5B%5Cw%5C%2F%5D%2B'
         41      > JMP                                                      ->47
   32    42    >   INIT_FCALL                                               'implode'
         43        SEND_VAL                                                 '%5Cw%2B'
         44        SEND_VAR                                                 !2
         45        DO_ICALL                                         $26     
         46        ASSIGN                                                   !4, $26
   35    47    >   CONCAT                                           ~28     '%2F%5E', !4
         48        CONCAT                                           ~29     ~28, '%24%2Fim'
         49        ASSIGN                                                   !4, ~29
   37    50        INIT_FCALL                                               'var_dump'
         51        SEND_VAR                                                 !4
         52        DO_ICALL                                                 
         53      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.38 ms | 1400 KiB | 23 Q