3v4l.org

run code in 500+ PHP versions simultaneously
<?php $str = "We have received ##AMOUNT## ##CURRENCY## for your OrderID n. ##ORDER_ID##"; $AMOUNT = 123; $CURRENCY = 'GBP'; $ORDER_ID = 20123; $find = ['AMOUNT', 'CURRENCY', 'ORDER_ID']; echo str_replace( array_map(function($v){ return '##'.$v.'##'; }, $find), compact(...$find), $str );
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ekHYB
function name:  (null)
number of ops:  18
compiled vars:  !0 = $str, !1 = $AMOUNT, !2 = $CURRENCY, !3 = $ORDER_ID, !4 = $find
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                       !0, 'We+have+received+%23%23AMOUNT%23%23+%23%23CURRENCY%23%23+for+your+OrderID+n.+%23%23ORDER_ID%23%23'
    4     1        ASSIGN                                                       !1, 123
    5     2        ASSIGN                                                       !2, 'GBP'
    6     3        ASSIGN                                                       !3, 20123
    8     4        ASSIGN                                                       !4, <array>
   11     5        INIT_FCALL                                                   'array_map'
          6        DECLARE_LAMBDA_FUNCTION                              ~10     [0]
          7        SEND_VAL                                                     ~10
          8        SEND_VAR                                                     !4
          9        DO_ICALL                                             $11     
   12    10        INIT_FCALL                                                   'compact'
         11        SEND_UNPACK                                                  !4
         12        CHECK_UNDEF_ARGS                                             
         13        DO_ICALL                                             $12     
   10    14        FRAMELESS_ICALL_3                str_replace         ~13     $11, $12
   13    15        OP_DATA                                                      !0
         16        ECHO                                                         ~13
   14    17      > 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/ekHYB
function name:  {closure:/in/ekHYB:11}
number of ops:  5
compiled vars:  !0 = $v
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   11     0  E >   RECV                                                 !0      
          1        CONCAT                                               ~1      '%23%23', !0
          2        CONCAT                                               ~2      ~1, '%23%23'
          3      > RETURN                                                       ~2
          4*     > RETURN                                                       null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
170.25 ms | 2586 KiB | 15 Q