3v4l.org

run code in 300+ PHP versions simultaneously
<?php $vars = [ 'code_user' => 'Loz', 'code_order' => 5504 ]; $template = 'Dear [code_user] your new order code is [code_order]!'; $result = preg_replace_callback('/\[[ ]{0,}([\w\_-]{1,})[ ]{0,}\]/', function ($match) use ($vars) { return array_key_exists($match[1], $vars) ? $vars[$match[1]] : ''; }, $template); echo $result;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/W2GFO
function name:  (null)
number of ops:  12
compiled vars:  !0 = $vars, !1 = $template, !2 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
    7     1        ASSIGN                                                   !1, 'Dear+%5Bcode_user%5D+your+new+order+code+is+%5Bcode_order%5D%21'
    9     2        INIT_FCALL                                               'preg_replace_callback'
          3        SEND_VAL                                                 '%2F%5C%5B%5B+%5D%7B0%2C%7D%28%5B%5Cw%5C_-%5D%7B1%2C%7D%29%5B+%5D%7B0%2C%7D%5C%5D%2F'
          4        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FW2GFO%3A9%240'
          5        BIND_LEXICAL                                             ~5, !0
   11     6        SEND_VAL                                                 ~5
          7        SEND_VAR                                                 !1
          8        DO_ICALL                                         $6      
    9     9        ASSIGN                                                   !2, $6
   13    10        ECHO                                                     !2
   14    11      > RETURN                                                   1

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

End of function %00%7Bclosure%7D%2Fin%2FW2GFO%3A9%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
126.69 ms | 1401 KiB | 15 Q