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)); preg_match_all('/\{(.*?)\}/', $string, $matches); foreach ($matches[1] as $value) { $string = str_replace('{'.$value.'}', $v[${$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/C1TJF
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'
   22     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
2 jumps found. (Code = 77) Position 1 = 19, Position 2 = 31
Branch analysis from position: 19
2 jumps found. (Code = 78) Position 1 = 20, Position 2 = 31
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
Branch analysis from position: 31
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 31
filename:       /in/C1TJF
function name:  parse
number of ops:  34
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
   12    12        INIT_FCALL                                               'preg_match_all'
         13        SEND_VAL                                                 '%2F%5C%7B%28.%2A%3F%29%5C%7D%2F'
         14        SEND_VAR                                                 !0
         15        SEND_REF                                                 !2
         16        DO_ICALL                                                 
   14    17        FETCH_DIM_R                                      ~7      !2, 1
         18      > FE_RESET_R                                       $8      ~7, ->31
         19    > > FE_FETCH_R                                               $8, !3, ->31
   16    20    >   INIT_FCALL                                               'str_replace'
         21        CONCAT                                           ~9      '%7B', !3
         22        CONCAT                                           ~10     ~9, '%7D'
         23        SEND_VAL                                                 ~10
         24        FETCH_R                      local               ~11     !3
         25        FETCH_DIM_R                                      ~12     !1, ~11
         26        SEND_VAL                                                 ~12
         27        SEND_VAR                                                 !0
         28        DO_ICALL                                         $13     
         29        ASSIGN                                                   !0, $13
   14    30      > JMP                                                      ->19
         31    >   FE_FREE                                                  $8
   19    32      > RETURN                                                   !0
   20    33*     > RETURN                                                   null

End of function parse

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
169.89 ms | 948 KiB | 21 Q