3v4l.org

run code in 300+ PHP versions simultaneously
<?php $tokens = [ ':rr'=>5, ':tipo'=>'\[A-Z]' ]; $regex = '/#([a-zA-z0-9_]+)(:[a-zA-Z]+)/'; $pattern = 'blog/#month:tipo/#year:rr'; echo $result = preg_replace($regex, "(?<$1>$2)", $pattern); echo PHP_EOL; echo $result = strtr($result, $tokens); /*echo preg_replace_callback($regex, function (array $matches) { $tokens = [ ':rr'=>5, ':tipo'=>'\[A-Z]' ]; echo "(?<{$matches[1]}>{$tokens[$matches[2]]})"; }, $pattern);*/
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/HWov0
function name:  (null)
number of ops:  18
compiled vars:  !0 = $tokens, !1 = $regex, !2 = $pattern, !3 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   10     1        ASSIGN                                                   !1, '%2F%23%28%5Ba-zA-z0-9_%5D%2B%29%28%3A%5Ba-zA-Z%5D%2B%29%2F'
   11     2        ASSIGN                                                   !2, 'blog%2F%23month%3Atipo%2F%23year%3Arr'
   13     3        INIT_FCALL                                               'preg_replace'
          4        SEND_VAR                                                 !1
          5        SEND_VAL                                                 '%28%3F%3C%241%3E%242%29'
          6        SEND_VAR                                                 !2
          7        DO_ICALL                                         $7      
          8        ASSIGN                                           ~8      !3, $7
          9        ECHO                                                     ~8
   14    10        ECHO                                                     '%0A'
   15    11        INIT_FCALL                                               'strtr'
         12        SEND_VAR                                                 !3
         13        SEND_VAR                                                 !0
         14        DO_ICALL                                         $9      
         15        ASSIGN                                           ~10     !3, $9
         16        ECHO                                                     ~10
   27    17      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
161.01 ms | 1394 KiB | 17 Q