3v4l.org

run code in 500+ PHP versions simultaneously
<?php $str = "{{{ a { b } c }} d &#123;&#123; e &#123; f &#x7d;&#x7d;&#x7d;&#x7d; g"; echo "\nstd: " . $str; function interpol_escape($value) { return str_replace( ['{', '}', '&#123;', '&#125;', '&#x7b;', '&#x7d;' ], ['{ ', '} ', '&#123; ', '&#125; ', '&#x7b; ', '&#x7d; '], $value ); } echo "\nstr: " . interpol_escape($str); function interpol_regex($value) { return preg_replace('/({|}|&#123;|&#125;|&#x7b;|&#x7d;)(?=\S)/', '$1 ', $value); } echo "\nreg: " . interpol_regex($str); echo "\nexp: { { { a { b } c } } d &#123; &#123; e &#123; f &#x7d; &#x7d; &#x7d; &#x7d; g";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PShvh
function name:  (null)
number of ops:  15
compiled vars:  !0 = $str
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, '%7B%7B%7B+a+%7B+b+%7D+c+%7D%7D+d+%26%23123%3B%26%23123%3B+e+%26%23123%3B+f+%26%23x7d%3B%26%23x7d%3B%26%23x7d%3B%26%23x7d%3B+g'
    5     1        CONCAT                                               ~2      '%0Astd%3A+', !0
          2        ECHO                                                         ~2
   16     3        INIT_FCALL                                                   'interpol_escape'
          4        SEND_VAR                                                     !0
          5        DO_FCALL                                          0  $3      
          6        CONCAT                                               ~4      '%0Astr%3A+', $3
          7        ECHO                                                         ~4
   23     8        INIT_FCALL                                                   'interpol_regex'
          9        SEND_VAR                                                     !0
         10        DO_FCALL                                          0  $5      
         11        CONCAT                                               ~6      '%0Areg%3A+', $5
         12        ECHO                                                         ~6
   25    13        ECHO                                                         '%0Aexp%3A+%7B+%7B+%7B+a+%7B+b+%7D+c+%7D+%7D+d+%26%23123%3B+%26%23123%3B+e+%26%23123%3B+f+%26%23x7d%3B+%26%23x7d%3B+%26%23x7d%3B+%26%23x7d%3B+g'
         14      > RETURN                                                       1

Function interpol_escape:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PShvh
function name:  interpol_escape
number of ops:  5
compiled vars:  !0 = $value
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    7     0  E >   RECV                                                 !0      
    9     1        FRAMELESS_ICALL_3                str_replace         ~1      <array>, <array>
   12     2        OP_DATA                                                      !0
          3      > RETURN                                                       ~1
   14     4*     > RETURN                                                       null

End of function interpol_escape

Function interpol_regex:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PShvh
function name:  interpol_regex
number of ops:  5
compiled vars:  !0 = $value
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   18     0  E >   RECV                                                 !0      
   20     1        FRAMELESS_ICALL_3                preg_replace        ~1      '%2F%28%7B%7C%7D%7C%26%23123%3B%7C%26%23125%3B%7C%26%23x7b%3B%7C%26%23x7d%3B%29%28%3F%3D%5CS%29%2F', '%241+'
          2        OP_DATA                                                      !0
          3      > RETURN                                                       ~1
   21     4*     > RETURN                                                       null

End of function interpol_regex

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
161.04 ms | 2273 KiB | 15 Q