3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str = "and with strange aeons even {{noun}} may {{verb}}"; $data = ['noun' => 'bird', 'verb' => 'fly']; $pattern = '/{{(' . implode('|', array_keys($data)) . ')}}/i'; echo preg_replace_callback($pattern, function($m) use($data){ return $data[strtolower($m[1])]; }, $str);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/nrQ4t
function name:  (null)
number of ops:  21
compiled vars:  !0 = $str, !1 = $data, !2 = $pattern
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 'and+with+strange+aeons+even+%7B%7Bnoun%7D%7D+may+%7B%7Bverb%7D%7D'
    4     1        ASSIGN                                                   !1, <array>
    6     2        INIT_FCALL                                               'implode'
          3        SEND_VAL                                                 '%7C'
          4        INIT_FCALL                                               'array_keys'
          5        SEND_VAR                                                 !1
          6        DO_ICALL                                         $5      
          7        SEND_VAR                                                 $5
          8        DO_ICALL                                         $6      
          9        CONCAT                                           ~7      '%2F%7B%7B%28', $6
         10        CONCAT                                           ~8      ~7, '%29%7D%7D%2Fi'
         11        ASSIGN                                                   !2, ~8
    7    12        INIT_FCALL                                               'preg_replace_callback'
         13        SEND_VAR                                                 !2
         14        DECLARE_LAMBDA_FUNCTION                          ~10     [0]
         15        BIND_LEXICAL                                             ~10, !1
    9    16        SEND_VAL                                                 ~10
         17        SEND_VAR                                                 !0
    7    18        DO_ICALL                                         $11     
    9    19        ECHO                                                     $11
         20      > 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/nrQ4t
function name:  {closure}
number of ops:  9
compiled vars:  !0 = $m, !1 = $data
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
    8     2        INIT_FCALL                                               'strtolower'
          3        FETCH_DIM_R                                      ~2      !0, 1
          4        SEND_VAL                                                 ~2
          5        DO_ICALL                                         $3      
          6        FETCH_DIM_R                                      ~4      !1, $3
          7      > RETURN                                                   ~4
    9     8*     > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
139.92 ms | 1002 KiB | 17 Q