3v4l.org

run code in 500+ PHP versions simultaneously
<?php function replaceString($string) { $array1 = ['mp', 'tm', 'de']; $array2 = ['MAP', 'TM', "DECIMAL"]; $first = substr($string, 0, -2); $last = substr($string, -2); $split = [ 'start' => $first, 'end' => $last, ]; foreach ($array1 as $key => $val) { if ($val == $split['end']) { $word = $split['start'].$array2[$key]; return $word; } } } $mystring = "samplemp"; echo replaceString($mystring)."\n";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fJCIY
function name:  (null)
number of ops:  7
compiled vars:  !0 = $mystring
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   22     0  E >   ASSIGN                                                       !0, 'samplemp'
   23     1        INIT_FCALL                                                   'replacestring'
          2        SEND_VAR                                                     !0
          3        DO_FCALL                                          0  $2      
          4        CONCAT                                               ~3      $2, '%0A'
          5        ECHO                                                         ~3
          6      > RETURN                                                       1

Function replacestring:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 12, Position 2 = 24
Branch analysis from position: 12
2 jumps found. (Code = 78) Position 1 = 13, Position 2 = 24
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 23
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
filename:       /in/fJCIY
function name:  replaceString
number of ops:  26
compiled vars:  !0 = $string, !1 = $array1, !2 = $array2, !3 = $first, !4 = $last, !5 = $split, !6 = $val, !7 = $key, !8 = $word
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   RECV                                                 !0      
    5     1        ASSIGN                                                       !1, <array>
    6     2        ASSIGN                                                       !2, <array>
    7     3        FRAMELESS_ICALL_3                substr              ~11     !0, 0
          4        OP_DATA                                                      -2
          5        ASSIGN                                                       !3, ~11
    8     6        FRAMELESS_ICALL_2                substr              ~13     !0, -2
          7        ASSIGN                                                       !4, ~13
   10     8        INIT_ARRAY                                           ~15     !3, 'start'
   11     9        ADD_ARRAY_ELEMENT                                    ~15     !4, 'end'
    9    10        ASSIGN                                                       !5, ~15
   13    11      > FE_RESET_R                                           $17     !1, ->24
         12    > > FE_FETCH_R                                           ~18     $17, !6, ->24
         13    >   ASSIGN                                                       !7, ~18
   14    14        FETCH_DIM_R                                          ~20     !5, 'end'
         15        IS_EQUAL                                                     !6, ~20
         16      > JMPZ                                                         ~21, ->23
   15    17    >   FETCH_DIM_R                                          ~22     !5, 'start'
         18        FETCH_DIM_R                                          ~23     !2, !7
         19        CONCAT                                               ~24     ~22, ~23
         20        ASSIGN                                                       !8, ~24
   16    21        FE_FREE                                                      $17
         22      > RETURN                                                       !8
   13    23    > > JMP                                                          ->12
         24    >   FE_FREE                                                      $17
   19    25      > RETURN                                                       null

End of function replacestring

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
223.8 ms | 2066 KiB | 16 Q