3v4l.org

run code in 300+ PHP versions simultaneously
<?php $text = "Hello {first_name}, from {company}. This is your email address: {email}. Your application for {team} has been approved."; $placeholders = ["company" => "contoso inc", "name" => "john doe", "email" => "me@contoso.com"]; echo preg_replace_callback('/\s*\{([^{}}]*)\}/', function ($match) use ($placeholders) { return isset($placeholders[$match[1]]) ? " " . $placeholders[$match[1]] : ""; }, $text);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Vcdo0
function name:  (null)
number of ops:  11
compiled vars:  !0 = $text, !1 = $placeholders
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 'Hello+%7Bfirst_name%7D%2C+from+%7Bcompany%7D.+This+is+your+email+address%3A+%7Bemail%7D.+Your+application+for+%7Bteam%7D+has+been+approved.'
    4     1        ASSIGN                                                   !1, <array>
    5     2        INIT_FCALL                                               'preg_replace_callback'
          3        SEND_VAL                                                 '%2F%5Cs%2A%5C%7B%28%5B%5E%7B%7D%7D%5D%2A%29%5C%7D%2F'
          4        DECLARE_LAMBDA_FUNCTION                          ~4      [0]
          5        BIND_LEXICAL                                             ~4, !1
    7     6        SEND_VAL                                                 ~4
          7        SEND_VAR                                                 !0
    5     8        DO_ICALL                                         $5      
    7     9        ECHO                                                     $5
         10      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 10
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Vcdo0
function name:  {closure}
number of ops:  13
compiled vars:  !0 = $match, !1 = $placeholders
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
    6     2        FETCH_DIM_R                                      ~2      !0, 1
          3        ISSET_ISEMPTY_DIM_OBJ                         0          !1, ~2
          4      > JMPZ                                                     ~3, ->10
          5    >   FETCH_DIM_R                                      ~4      !0, 1
          6        FETCH_DIM_R                                      ~5      !1, ~4
          7        CONCAT                                           ~6      '+', ~5
          8        QM_ASSIGN                                        ~7      ~6
          9      > JMP                                                      ->11
         10    >   QM_ASSIGN                                        ~7      ''
         11    > > RETURN                                                   ~7
    7    12*     > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
137.81 ms | 1011 KiB | 14 Q