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 = '#nombre:tipo'; echo preg_replace($regex, "(?<$1>{$tokens[${2}]})", $pattern); /*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/NsXVN
function name:  (null)
number of ops:  14
compiled vars:  !0 = $tokens, !1 = $regex, !2 = $pattern, !3 = $2
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, '%23nombre%3Atipo'
   13     3        INIT_FCALL                                               'preg_replace'
          4        SEND_VAR                                                 !1
          5        ROPE_INIT                                     3  ~9      '%28%3F%3C%241%3E'
          6        FETCH_DIM_R                                      ~7      !0, !3
          7        ROPE_ADD                                      1  ~9      ~9, ~7
          8        ROPE_END                                      2  ~8      ~9, '%29'
          9        SEND_VAL                                                 ~8
         10        SEND_VAR                                                 !2
         11        DO_ICALL                                         $11     
         12        ECHO                                                     $11
   27    13      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
160.71 ms | 1394 KiB | 15 Q