3v4l.org

run code in 300+ PHP versions simultaneously
<?php $data = [ 0 => 'john', 1 => 'robinson', 2 => '27-08-1980', 3 => 'football', 4 => 'pizza', ]; $template = "{0} {1} birthday {2} <br /> Hobbie : {3} <br /> favorite : {4}"; $string = preg_replace_callback( '/\{(\d+)\}/', function ($matches) use ($data) { return $data[$matches[1]]; }, $template ); echo $string;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ESCmH
function name:  (null)
number of ops:  12
compiled vars:  !0 = $data, !1 = $template, !2 = $string
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   11     1        ASSIGN                                                   !1, '%7B0%7D+%7B1%7D+birthday+%7B2%7D+%3Cbr+%2F%3E+Hobbie+%3A+%7B3%7D++%3Cbr+%2F%3E+favorite+%3A+%7B4%7D'
   13     2        INIT_FCALL                                               'preg_replace_callback'
   14     3        SEND_VAL                                                 '%2F%5C%7B%28%5Cd%2B%29%5C%7D%2F'
   15     4        DECLARE_LAMBDA_FUNCTION                          ~5      [0]
          5        BIND_LEXICAL                                             ~5, !0
   17     6        SEND_VAL                                                 ~5
   18     7        SEND_VAR                                                 !1
   13     8        DO_ICALL                                         $6      
          9        ASSIGN                                                   !2, $6
   21    10        ECHO                                                     !2
         11      > 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/ESCmH
function name:  {closure}
number of ops:  6
compiled vars:  !0 = $matches, !1 = $data
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
   16     2        FETCH_DIM_R                                      ~2      !0, 1
          3        FETCH_DIM_R                                      ~3      !1, ~2
          4      > RETURN                                                   ~3
   17     5*     > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
246.8 ms | 999 KiB | 14 Q