3v4l.org

run code in 300+ PHP versions simultaneously
<?php $items = json_decode('[ {"title":"Title #1", "text":"Text #1"}, {"title":"Title #2", "text":"Text #2"} ]'); $itemTmpl = "<h3 class='foo'>{title}</h3><div class='bar'>{text}</div>"; $html = []; foreach ($items as $item) { $html[] = preg_replace_callback( '/{([a-z]+)}/', fn($m) => $item->{$m[1]}, $itemTmpl ); } var_export($html);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 7, Position 2 = 18
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 18
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
filename:       /in/i54CV
function name:  (null)
number of ops:  23
compiled vars:  !0 = $items, !1 = $itemTmpl, !2 = $html, !3 = $item
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'json_decode'
          1        SEND_VAL                                                 '%5B%0A++++%7B%22title%22%3A%22Title+%231%22%2C+%22text%22%3A%22Text+%231%22%7D%2C%0A++++%7B%22title%22%3A%22Title+%232%22%2C+%22text%22%3A%22Text+%232%22%7D%0A%5D'
          2        DO_ICALL                                         $4      
          3        ASSIGN                                                   !0, $4
    8     4        ASSIGN                                                   !1, '%3Ch3+class%3D%27foo%27%3E%7Btitle%7D%3C%2Fh3%3E%3Cdiv+class%3D%27bar%27%3E%7Btext%7D%3C%2Fdiv%3E'
   10     5        ASSIGN                                                   !2, <array>
   11     6      > FE_RESET_R                                       $8      !0, ->18
          7    > > FE_FETCH_R                                               $8, !3, ->18
   12     8    >   INIT_FCALL                                               'preg_replace_callback'
   13     9        SEND_VAL                                                 '%2F%7B%28%5Ba-z%5D%2B%29%7D%2F'
   14    10        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2Fi54CV%3A14%240'
         11        BIND_LEXICAL                                             ~10, !3
         12        SEND_VAL                                                 ~10
   15    13        SEND_VAR                                                 !1
         14        DO_ICALL                                         $11     
   12    15        ASSIGN_DIM                                               !2
   15    16        OP_DATA                                                  $11
   11    17      > JMP                                                      ->7
         18    >   FE_FREE                                                  $8
   18    19        INIT_FCALL                                               'var_export'
         20        SEND_VAR                                                 !2
         21        DO_ICALL                                                 
         22      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2Fi54CV%3A14%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/i54CV
function name:  {closure}
number of ops:  6
compiled vars:  !0 = $m, !1 = $item
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
          2        FETCH_DIM_R                                      ~2      !0, 1
          3        FETCH_OBJ_R                                      ~3      !1, ~2
          4      > RETURN                                                   ~3
          5*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2Fi54CV%3A14%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
165.22 ms | 1396 KiB | 19 Q