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)] = '') { 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 = 25, Position 2 = 41
Branch analysis from position: 25
2 jumps found. (Code = 43) Position 1 = 31, Position 2 = 37
Branch analysis from position: 31
1 jumps found. (Code = 42) Position 1 = 39
Branch analysis from position: 39
1 jumps found. (Code = 42) Position 1 = 46
Branch analysis from position: 46
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 37
1 jumps found. (Code = 42) Position 1 = 46
Branch analysis from position: 46
Branch analysis from position: 41
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
filename:       /in/MKqYf
function name:  (null)
number of ops:  53
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        ASSIGN_DIM                                       ~15     !2, ~14
         23        OP_DATA                                                  ''
         24      > JMPZ                                                     ~15, ->41
   20    25    >   INIT_FCALL                                               'array_pop'
         26        SEND_REF                                                 !2
         27        DO_ICALL                                                 
   22    28        COUNT                                            ~17     !2
         29        IS_SMALLER                                               1, ~17
         30      > JMPZ                                                     ~18, ->37
   23    31    >   INIT_FCALL                                               'implode'
         32        SEND_VAL                                                 '%5Cw%2B'
         33        SEND_VAR                                                 !2
         34        DO_ICALL                                         $19     
         35        ASSIGN                                                   !4, $19
         36      > JMP                                                      ->39
   26    37    >   FETCH_DIM_R                                      ~21     !2, 0
         38        ASSIGN                                                   !4, ~21
   29    39    >   ASSIGN_OP                                     8          !4, '%5B%5Cw%5C%2F%5D%2B'
         40      > JMP                                                      ->46
   32    41    >   INIT_FCALL                                               'implode'
         42        SEND_VAL                                                 '%5Cw%2B'
         43        SEND_VAR                                                 !2
         44        DO_ICALL                                         $24     
         45        ASSIGN                                                   !4, $24
   35    46    >   CONCAT                                           ~26     '%2F%5E', !4
         47        CONCAT                                           ~27     ~26, '%24%2Fim'
         48        ASSIGN                                                   !4, ~27
   37    49        INIT_FCALL                                               'var_dump'
         50        SEND_VAR                                                 !4
         51        DO_ICALL                                                 
         52      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
149.3 ms | 1400 KiB | 23 Q