3v4l.org

run code in 300+ PHP versions simultaneously
<?php $optimization_prompt = '[not a key] The product title is [title] and the price is [price] and this product link is [link]'; $get_product = ['title' => 'theTitle', 'price' => 45, 'link' => 'https://thelink.com']; $result = preg_replace_callback( '~\[([^][]+)]~', fn($m) => $get_product[$m[1]] ?? $m[0], $optimization_prompt ); echo $result;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jcQsB
function name:  (null)
number of ops:  12
compiled vars:  !0 = $optimization_prompt, !1 = $get_product, !2 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%5Bnot+a+key%5D+The+product+title+is+%5Btitle%5D+and+the+price+is+%5Bprice%5D+and+this+product+link+is+%5Blink%5D'
    4     1        ASSIGN                                                   !1, <array>
    6     2        INIT_FCALL                                               'preg_replace_callback'
    7     3        SEND_VAL                                                 '%7E%5C%5B%28%5B%5E%5D%5B%5D%2B%29%5D%7E'
    8     4        DECLARE_LAMBDA_FUNCTION                          ~5      [0]
          5        BIND_LEXICAL                                             ~5, !1
          6        SEND_VAL                                                 ~5
    9     7        SEND_VAR                                                 !0
    6     8        DO_ICALL                                         $6      
          9        ASSIGN                                                   !2, $6
   12    10        ECHO                                                     !2
   13    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/jcQsB
function name:  {closure}
number of ops:  9
compiled vars:  !0 = $m, !1 = $get_product
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
          2        FETCH_DIM_R                                      ~2      !0, 1
          3        FETCH_DIM_IS                                     ~3      !1, ~2
          4        COALESCE                                         ~4      ~3
          5        FETCH_DIM_R                                      ~5      !0, 0
          6        QM_ASSIGN                                        ~4      ~5
          7      > RETURN                                                   ~4
          8*     > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
183.48 ms | 1000 KiB | 14 Q