3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string = "I need to replace {X} and {Y}"; $X = 'something'; $Y = 'something else'; function parse($string) { $v = sprintf('%s%s%s%s%s%s%s', chr(71), chr(76), chr(79), chr(66), chr(65), chr(76), chr(83)); var_dump($v); return; preg_match_all('/\{(.*?)\}/', $string, $matches); foreach ($matches[1] as $value) { $string = str_replace('{'.$value.'}', ${$value}, $string); } return $string; } echo parse($string);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/rLdm2
function name:  (null)
number of ops:  8
compiled vars:  !0 = $string, !1 = $X, !2 = $Y
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 'I+need+to+replace+%7BX%7D+and+%7BY%7D'
    4     1        ASSIGN                                                   !1, 'something'
    5     2        ASSIGN                                                   !2, 'something+else'
   25     3        INIT_FCALL                                               'parse'
          4        SEND_VAR                                                 !0
          5        DO_FCALL                                      0  $6      
          6        ECHO                                                     $6
          7      > RETURN                                                   1

Function parse:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/rLdm2
function name:  parse
number of ops:  37
compiled vars:  !0 = $string, !1 = $v, !2 = $matches, !3 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
    9     1        INIT_FCALL                                               'sprintf'
          2        SEND_VAL                                                 '%25s%25s%25s%25s%25s%25s%25s'
          3        SEND_VAL                                                 'G'
          4        SEND_VAL                                                 'L'
          5        SEND_VAL                                                 'O'
          6        SEND_VAL                                                 'B'
          7        SEND_VAL                                                 'A'
          8        SEND_VAL                                                 'L'
          9        SEND_VAL                                                 'S'
         10        DO_ICALL                                         $4      
         11        ASSIGN                                                   !1, $4
   11    12        INIT_FCALL                                               'var_dump'
         13        SEND_VAR                                                 !1
         14        DO_ICALL                                                 
   13    15      > RETURN                                                   null
   15    16*       INIT_FCALL                                               'preg_match_all'
         17*       SEND_VAL                                                 '%2F%5C%7B%28.%2A%3F%29%5C%7D%2F'
         18*       SEND_VAR                                                 !0
         19*       SEND_REF                                                 !2
         20*       DO_ICALL                                                 
   17    21*       FETCH_DIM_R                                      ~8      !2, 1
         22*       FE_RESET_R                                       $9      ~8, ->34
         23*       FE_FETCH_R                                               $9, !3, ->34
   19    24*       INIT_FCALL                                               'str_replace'
         25*       CONCAT                                           ~10     '%7B', !3
         26*       CONCAT                                           ~11     ~10, '%7D'
         27*       SEND_VAL                                                 ~11
         28*       FETCH_R                      local               ~12     !3
         29*       SEND_VAL                                                 ~12
         30*       SEND_VAR                                                 !0
         31*       DO_ICALL                                         $13     
         32*       ASSIGN                                                   !0, $13
   17    33*       JMP                                                      ->23
         34*       FE_FREE                                                  $9
   22    35*       RETURN                                                   !0
   23    36*     > RETURN                                                   null

End of function parse

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.02 ms | 1394 KiB | 22 Q