3v4l.org

run code in 300+ PHP versions simultaneously
<?php $tst = '!!!!'; $a = '@@@'; $template = '{{$tst}}test{{$a}}'; if (preg_match_all("/{{(.*?)}}/", $template, $m)) { foreach ($m[1] as $i => $varname) { echo $varname.PHP_EOL.$m[0][$i].PHP_EOL; $template = str_replace($m[0][$i], sprintf('$%s', $varname), $template); } } echo $template;
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 33
Branch analysis from position: 9
2 jumps found. (Code = 77) Position 1 = 11, Position 2 = 32
Branch analysis from position: 11
2 jumps found. (Code = 78) Position 1 = 12, Position 2 = 32
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
Branch analysis from position: 32
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 32
Branch analysis from position: 33
filename:       /in/ftHaX
function name:  (null)
number of ops:  35
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%28.%2A%3F%29%7D%7D%2F'
          5        SEND_VAR                                                 !2
          6        SEND_REF                                                 !3
          7        DO_ICALL                                         $9      
          8      > JMPZ                                                     $9, ->33
    8     9    >   FETCH_DIM_R                                      ~10     !3, 1
         10      > FE_RESET_R                                       $11     ~10, ->32
         11    > > FE_FETCH_R                                       ~12     $11, !4, ->32
         12    >   ASSIGN                                                   !5, ~12
    9    13        CONCAT                                           ~14     !4, '%0A'
         14        FETCH_DIM_R                                      ~15     !3, 0
         15        FETCH_DIM_R                                      ~16     ~15, !5
         16        CONCAT                                           ~17     ~14, ~16
         17        CONCAT                                           ~18     ~17, '%0A'
         18        ECHO                                                     ~18
   10    19        INIT_FCALL                                               'str_replace'
         20        FETCH_DIM_R                                      ~19     !3, 0
         21        FETCH_DIM_R                                      ~20     ~19, !5
         22        SEND_VAL                                                 ~20
         23        INIT_FCALL                                               'sprintf'
         24        SEND_VAL                                                 '%24%25s'
         25        SEND_VAR                                                 !4
         26        DO_ICALL                                         $21     
         27        SEND_VAR                                                 $21
         28        SEND_VAR                                                 !2
         29        DO_ICALL                                         $22     
         30        ASSIGN                                                   !2, $22
    8    31      > JMP                                                      ->11
         32    >   FE_FREE                                                  $11
   14    33    >   ECHO                                                     !2
         34      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
158.3 ms | 1396 KiB | 19 Q