3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string= '[mycode="gallery" type="single" id="1" data="only"]'; echo preg_replace_callback('/\[([^\]]+)\]/', function($match) { $string = preg_replace('/\h*mycode="([^"]+)"\h*/', '$1/mycode', $match[1]); $string = preg_replace('/\h*type="([^"]+)"\h*/', 'mycode_$1.php', $string); $string = preg_replace('/\h*id="([^"]+)"\h*/', '?id=$1', $string); $string = preg_replace('/\h*data="([^"]+)"\h*/', '&data=$1', $string); return $string; }, $string);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/KDD0B
function name:  (null)
number of ops:  9
compiled vars:  !0 = $string
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, '%5Bmycode%3D%22gallery%22+type%3D%22single%22+id%3D%221%22+data%3D%22only%22%5D'
    3     1        INIT_FCALL                                               'preg_replace_callback'
          2        SEND_VAL                                                 '%2F%5C%5B%28%5B%5E%5C%5D%5D%2B%29%5C%5D%2F'
          3        DECLARE_LAMBDA_FUNCTION                          ~2      [0]
    9     4        SEND_VAL                                                 ~2
          5        SEND_VAR                                                 !0
    3     6        DO_ICALL                                         $3      
    9     7        ECHO                                                     $3
          8      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/KDD0B
function name:  {closure}
number of ops:  28
compiled vars:  !0 = $match, !1 = $string
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    4     1        INIT_FCALL                                               'preg_replace'
          2        SEND_VAL                                                 '%2F%5Ch%2Amycode%3D%22%28%5B%5E%22%5D%2B%29%22%5Ch%2A%2F'
          3        SEND_VAL                                                 '%241%2Fmycode'
          4        FETCH_DIM_R                                      ~2      !0, 1
          5        SEND_VAL                                                 ~2
          6        DO_ICALL                                         $3      
          7        ASSIGN                                                   !1, $3
    5     8        INIT_FCALL                                               'preg_replace'
          9        SEND_VAL                                                 '%2F%5Ch%2Atype%3D%22%28%5B%5E%22%5D%2B%29%22%5Ch%2A%2F'
         10        SEND_VAL                                                 'mycode_%241.php'
         11        SEND_VAR                                                 !1
         12        DO_ICALL                                         $5      
         13        ASSIGN                                                   !1, $5
    6    14        INIT_FCALL                                               'preg_replace'
         15        SEND_VAL                                                 '%2F%5Ch%2Aid%3D%22%28%5B%5E%22%5D%2B%29%22%5Ch%2A%2F'
         16        SEND_VAL                                                 '%3Fid%3D%241'
         17        SEND_VAR                                                 !1
         18        DO_ICALL                                         $7      
         19        ASSIGN                                                   !1, $7
    7    20        INIT_FCALL                                               'preg_replace'
         21        SEND_VAL                                                 '%2F%5Ch%2Adata%3D%22%28%5B%5E%22%5D%2B%29%22%5Ch%2A%2F'
         22        SEND_VAL                                                 '%26data%3D%241'
         23        SEND_VAR                                                 !1
         24        DO_ICALL                                         $9      
         25        ASSIGN                                                   !1, $9
    8    26      > RETURN                                                   !1
    9    27*     > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
138.56 ms | 1004 KiB | 15 Q