3v4l.org

run code in 300+ PHP versions simultaneously
<?php $body = "This is a body of {{awesome}} text {{blabla}} from a book."; $count = 0; $terms[] = '1'; $terms[] = '2'; echo preg_replace_callback('/\{{2}(.*?)\}{2}/',function($match) use (&$count, $terms) { $return = !empty($terms[$count]) ? $terms[$count] : 'Default value for unknown term'; $count++; return $return; }, $body);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Ktaod
function name:  (null)
number of ops:  16
compiled vars:  !0 = $body, !1 = $count, !2 = $terms
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, 'This+is+a+body+of+%7B%7Bawesome%7D%7D+text+%7B%7Bblabla%7D%7D+from+a+book.'
    3     1        ASSIGN                                                   !1, 0
    4     2        ASSIGN_DIM                                               !2
          3        OP_DATA                                                  '1'
    5     4        ASSIGN_DIM                                               !2
          5        OP_DATA                                                  '2'
    6     6        INIT_FCALL                                               'preg_replace_callback'
          7        SEND_VAL                                                 '%2F%5C%7B%7B2%7D%28.%2A%3F%29%5C%7D%7B2%7D%2F'
          8        DECLARE_LAMBDA_FUNCTION                          ~7      [0]
          9        BIND_LEXICAL                                             ~7, !1
         10        BIND_LEXICAL                                             ~7, !2
   10    11        SEND_VAL                                                 ~7
         12        SEND_VAR                                                 !0
    6    13        DO_ICALL                                         $8      
   10    14        ECHO                                                     $8
         15      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 9
Branch analysis from position: 6
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/Ktaod
function name:  {closure}
number of ops:  14
compiled vars:  !0 = $match, !1 = $count, !2 = $terms, !3 = $return
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
          2        BIND_STATIC                                              !2
    7     3        ISSET_ISEMPTY_DIM_OBJ                         1  ~4      !2, !1
          4        BOOL_NOT                                         ~5      ~4
          5      > JMPZ                                                     ~5, ->9
          6    >   FETCH_DIM_R                                      ~6      !2, !1
          7        QM_ASSIGN                                        ~7      ~6
          8      > JMP                                                      ->10
          9    >   QM_ASSIGN                                        ~7      'Default+value+for+unknown+term'
         10    >   ASSIGN                                                   !3, ~7
    8    11        PRE_INC                                                  !1
    9    12      > RETURN                                                   !3
   10    13*     > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
159.86 ms | 1011 KiB | 14 Q