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); //Случай, когда * находится в конце строки - возможны любые вложенные пути 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';
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 = 22, Position 2 = 38
Branch analysis from position: 22
2 jumps found. (Code = 43) Position 1 = 28, Position 2 = 34
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 36
Branch analysis from position: 36
1 jumps found. (Code = 42) Position 1 = 43
Branch analysis from position: 43
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 34
1 jumps found. (Code = 42) Position 1 = 43
Branch analysis from position: 43
Branch analysis from position: 38
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
filename:       /in/qZ0QZ
function name:  (null)
number of ops:  47
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
   17    18        COUNT                                            ~13     !2
         19        ASSIGN_DIM                                       ~14     !2, ~13
         20        OP_DATA                                                  ''
         21      > JMPZ                                                     ~14, ->38
   18    22    >   INIT_FCALL                                               'array_pop'
         23        SEND_REF                                                 !2
         24        DO_ICALL                                                 
   19    25        COUNT                                            ~16     !2
         26        IS_SMALLER                                               1, ~16
         27      > JMPZ                                                     ~17, ->34
   20    28    >   INIT_FCALL                                               'implode'
         29        SEND_VAL                                                 '%5Cw%2B'
         30        SEND_VAR                                                 !2
         31        DO_ICALL                                         $18     
         32        ASSIGN                                                   !4, $18
         33      > JMP                                                      ->36
   23    34    >   FETCH_DIM_R                                      ~20     !2, 0
         35        ASSIGN                                                   !4, ~20
   26    36    >   ASSIGN_OP                                     8          !4, '%5B%5Cw%5C%2F%5D%2B'
         37      > JMP                                                      ->43
   29    38    >   INIT_FCALL                                               'implode'
         39        SEND_VAL                                                 '%5Cw%2B'
         40        SEND_VAR                                                 !2
         41        DO_ICALL                                         $23     
         42        ASSIGN                                                   !4, $23
   32    43    >   CONCAT                                           ~25     '%2F%5E', !4
         44        CONCAT                                           ~26     ~25, '%24%2Fim'
         45        ASSIGN                                                   !4, ~26
         46      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
169.68 ms | 1400 KiB | 21 Q