3v4l.org

run code in 300+ PHP versions simultaneously
<?php function fillTemplate($templateString, array $searchReplaceArray) { return str_replace( array_map(function($value) { return "{{" . $value . "}}"; }, array_keys($searchReplaceArray)), $searchReplaceArray, $templateString ); } echo fillTemplate( "Hello {{name}} welcome to {{company_name}}", ['name' => 'max', 'company_name' => 'Stack Exchange'] );
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/rh0KX
function name:  (null)
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   INIT_FCALL                                               'filltemplate'
   13     1        SEND_VAL                                                 'Hello+%7B%7Bname%7D%7D+welcome+to+%7B%7Bcompany_name%7D%7D'
   14     2        SEND_VAL                                                 <array>
   12     3        DO_FCALL                                      0  $0      
   14     4        ECHO                                                     $0
   15     5      > RETURN                                                   1

Function filltemplate:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/rh0KX
function name:  fillTemplate
number of ops:  17
compiled vars:  !0 = $templateString, !1 = $searchReplaceArray
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    4     2        INIT_FCALL                                               'str_replace'
    5     3        INIT_FCALL                                               'array_map'
          4        DECLARE_LAMBDA_FUNCTION                          ~2      [0]
          5        SEND_VAL                                                 ~2
          6        INIT_FCALL                                               'array_keys'
          7        SEND_VAR                                                 !1
          8        DO_ICALL                                         $3      
          9        SEND_VAR                                                 $3
         10        DO_ICALL                                         $4      
         11        SEND_VAR                                                 $4
    6    12        SEND_VAR                                                 !1
    7    13        SEND_VAR                                                 !0
    4    14        DO_ICALL                                         $5      
    7    15      > RETURN                                                   $5
    9    16*     > RETURN                                                   null


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/rh0KX
function name:  {closure}
number of ops:  5
compiled vars:  !0 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
          1        CONCAT                                           ~1      '%7B%7B', !0
          2        CONCAT                                           ~2      ~1, '%7D%7D'
          3      > RETURN                                                   ~2
          4*     > RETURN                                                   null

End of Dynamic Function 0

End of function filltemplate

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
138.63 ms | 1005 KiB | 17 Q