3v4l.org

run code in 300+ 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[1]) { $word = $split[0].$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/rZDiJ
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 = 18, Position 2 = 30
Branch analysis from position: 18
2 jumps found. (Code = 78) Position 1 = 19, Position 2 = 30
Branch analysis from position: 19
2 jumps found. (Code = 43) Position 1 = 23, Position 2 = 29
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 29
1 jumps found. (Code = 42) Position 1 = 18
Branch analysis from position: 18
Branch analysis from position: 30
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 30
filename:       /in/rZDiJ
function name:  replaceString
number of ops:  32
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        INIT_FCALL                                               'substr'
          4        SEND_VAR                                                 !0
          5        SEND_VAL                                                 0
          6        SEND_VAL                                                 -2
          7        DO_ICALL                                         $11     
          8        ASSIGN                                                   !3, $11
    8     9        INIT_FCALL                                               'substr'
         10        SEND_VAR                                                 !0
         11        SEND_VAL                                                 -2
         12        DO_ICALL                                         $13     
         13        ASSIGN                                                   !4, $13
   10    14        INIT_ARRAY                                       ~15     !3, 'start'
   11    15        ADD_ARRAY_ELEMENT                                ~15     !4, 'end'
    9    16        ASSIGN                                                   !5, ~15
   13    17      > FE_RESET_R                                       $17     !1, ->30
         18    > > FE_FETCH_R                                       ~18     $17, !6, ->30
         19    >   ASSIGN                                                   !7, ~18
   14    20        FETCH_DIM_R                                      ~20     !5, 1
         21        IS_EQUAL                                                 !6, ~20
         22      > JMPZ                                                     ~21, ->29
   15    23    >   FETCH_DIM_R                                      ~22     !5, 0
         24        FETCH_DIM_R                                      ~23     !2, !7
         25        CONCAT                                           ~24     ~22, ~23
         26        ASSIGN                                                   !8, ~24
   16    27        FE_FREE                                                  $17
         28      > RETURN                                                   !8
   13    29    > > JMP                                                      ->18
         30    >   FE_FREE                                                  $17
   19    31      > RETURN                                                   null

End of function replacestring

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
145.87 ms | 1406 KiB | 17 Q