3v4l.org

run code in 300+ PHP versions simultaneously
<?php $body = "This question is a {{x}} of {{y}} within SO."; $text = ['possible duplicate', '@21100035']; echo preg_replace_callback('~{{[^{}]++}}~', function($m) use ($text, &$count) { return $text[(int)$count++] ?? $m[0]; }, $body, -1, $count);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Hhh8v
function name:  (null)
number of ops:  14
compiled vars:  !0 = $body, !1 = $text, !2 = $count
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 'This+question+is+a+%7B%7Bx%7D%7D+of+%7B%7By%7D%7D+within+SO.'
    4     1        ASSIGN                                                   !1, <array>
    5     2        INIT_FCALL                                               'preg_replace_callback'
          3        SEND_VAL                                                 '%7E%7B%7B%5B%5E%7B%7D%5D%2B%2B%7D%7D%7E'
          4        DECLARE_LAMBDA_FUNCTION                          ~5      [0]
          5        BIND_LEXICAL                                             ~5, !1
          6        BIND_LEXICAL                                             ~5, !2
    7     7        SEND_VAL                                                 ~5
          8        SEND_VAR                                                 !0
          9        SEND_VAL                                                 -1
         10        SEND_REF                                                 !2
    5    11        DO_ICALL                                         $6      
    7    12        ECHO                                                     $6
         13      > 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/Hhh8v
function name:  {closure}
number of ops:  11
compiled vars:  !0 = $m, !1 = $text, !2 = $count
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
          2        BIND_STATIC                                              !2
    6     3        POST_INC                                         ~3      !2
          4        CAST                                          4  ~4      ~3
          5        FETCH_DIM_IS                                     ~5      !1, ~4
          6        COALESCE                                         ~6      ~5
          7        FETCH_DIM_R                                      ~7      !0, 0
          8        QM_ASSIGN                                        ~6      ~7
          9      > RETURN                                                   ~6
    7    10*     > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
149.93 ms | 1010 KiB | 14 Q