3v4l.org

run code in 300+ PHP versions simultaneously
<?php $tst = '!!!!'; $a = '@@@'; $template = '{{$tst}}test{{$a}}'; if (preg_match_all("/{{\$(.*?)}}/", $template, $m)) { print_r($m); foreach ($m[1] as $i => $varname) { echo strval($varname).PHP_EOL.$m[0][$i].'===='.sprintf('$%s', $varname).PHP_EOL; $template = str_replace($m[0][$i], $$varname, $template); } } echo $template;
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 40
Branch analysis from position: 9
2 jumps found. (Code = 77) Position 1 = 14, Position 2 = 39
Branch analysis from position: 14
2 jumps found. (Code = 78) Position 1 = 15, Position 2 = 39
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
Branch analysis from position: 39
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 39
Branch analysis from position: 40
filename:       /in/OMrs2
function name:  (null)
number of ops:  42
compiled vars:  !0 = $tst, !1 = $a, !2 = $template, !3 = $m, !4 = $varname, !5 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%21%21%21%21'
    4     1        ASSIGN                                                   !1, '%40%40%40'
    5     2        ASSIGN                                                   !2, '%7B%7B%24tst%7D%7Dtest%7B%7B%24a%7D%7D'
    7     3        INIT_FCALL                                               'preg_match_all'
          4        SEND_VAL                                                 '%2F%7B%7B%24%28.%2A%3F%29%7D%7D%2F'
          5        SEND_VAR                                                 !2
          6        SEND_REF                                                 !3
          7        DO_ICALL                                         $9      
          8      > JMPZ                                                     $9, ->40
    8     9    >   INIT_FCALL                                               'print_r'
         10        SEND_VAR                                                 !3
         11        DO_ICALL                                                 
    9    12        FETCH_DIM_R                                      ~11     !3, 1
         13      > FE_RESET_R                                       $12     ~11, ->39
         14    > > FE_FETCH_R                                       ~13     $12, !4, ->39
         15    >   ASSIGN                                                   !5, ~13
   10    16        CAST                                          6  ~15     !4
         17        CONCAT                                           ~16     ~15, '%0A'
         18        FETCH_DIM_R                                      ~17     !3, 0
         19        FETCH_DIM_R                                      ~18     ~17, !5
         20        CONCAT                                           ~19     ~16, ~18
         21        CONCAT                                           ~20     ~19, '%3D%3D%3D%3D'
         22        INIT_FCALL                                               'sprintf'
         23        SEND_VAL                                                 '%24%25s'
         24        SEND_VAR                                                 !4
         25        DO_ICALL                                         $21     
         26        CONCAT                                           ~22     ~20, $21
         27        CONCAT                                           ~23     ~22, '%0A'
         28        ECHO                                                     ~23
   11    29        INIT_FCALL                                               'str_replace'
         30        FETCH_DIM_R                                      ~24     !3, 0
         31        FETCH_DIM_R                                      ~25     ~24, !5
         32        SEND_VAL                                                 ~25
         33        FETCH_R                      local               ~26     !4
         34        SEND_VAL                                                 ~26
         35        SEND_VAR                                                 !2
         36        DO_ICALL                                         $27     
         37        ASSIGN                                                   !2, $27
    9    38      > JMP                                                      ->14
         39    >   FE_FREE                                                  $12
   14    40    >   ECHO                                                     !2
         41      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.32 ms | 1400 KiB | 21 Q