3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = array ( 'abc' => 'Test', 'def' => 'Variable', 'ghi' => 'Change' ); $string ='This is just a %!abc!% String and i wanna %!ghi!% the %!def!%'; $regexes = array_map(function ($k) { return "/" . preg_quote("%!$k!%") . "/"; }, array_keys($array)); $string = preg_replace($regexes, $array, $string); echo $string;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/mAh7o
function name:  (null)
number of ops:  19
compiled vars:  !0 = $array, !1 = $string, !2 = $regexes
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    4     1        ASSIGN                                                   !1, 'This+is+just+a+%25%21abc%21%25+String+and+i+wanna+%25%21ghi%21%25+the+%25%21def%21%25'
    5     2        INIT_FCALL                                               'array_map'
          3        DECLARE_LAMBDA_FUNCTION                          ~5      [0]
          4        SEND_VAL                                                 ~5
          5        INIT_FCALL                                               'array_keys'
          6        SEND_VAR                                                 !0
          7        DO_ICALL                                         $6      
          8        SEND_VAR                                                 $6
          9        DO_ICALL                                         $7      
         10        ASSIGN                                                   !2, $7
    6    11        INIT_FCALL                                               'preg_replace'
         12        SEND_VAR                                                 !2
         13        SEND_VAR                                                 !0
         14        SEND_VAR                                                 !1
         15        DO_ICALL                                         $9      
         16        ASSIGN                                                   !1, $9
    7    17        ECHO                                                     !1
    8    18      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/mAh7o
function name:  {closure}
number of ops:  11
compiled vars:  !0 = $k
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
          1        INIT_FCALL                                               'preg_quote'
          2        ROPE_INIT                                     3  ~2      '%25%21'
          3        ROPE_ADD                                      1  ~2      ~2, !0
          4        ROPE_END                                      2  ~1      ~2, '%21%25'
          5        SEND_VAL                                                 ~1
          6        DO_ICALL                                         $4      
          7        CONCAT                                           ~5      '%2F', $4
          8        CONCAT                                           ~6      ~5, '%2F'
          9      > RETURN                                                   ~6
         10*     > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
145.12 ms | 1009 KiB | 17 Q