3v4l.org

run code in 300+ PHP versions simultaneously
<?php function makePalindrome($word){ $result = 0; $chars = str_split($word); foreach($chars as $index => $char){ $ascii = ord($char); if(!(($ascii>=97 && $index==0) || ($ascii<=122 && $index == count($chars)))){ $result+=$ascii-97+1; } } return $result; } $test='abcde'; echo makePalindrome($test);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/CuLAu
function name:  (null)
number of ops:  6
compiled vars:  !0 = $test
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   ASSIGN                                                   !0, 'abcde'
   24     1        INIT_FCALL                                               'makepalindrome'
          2        SEND_VAR                                                 !0
          3        DO_FCALL                                      0  $2      
          4        ECHO                                                     $2
          5      > RETURN                                                   1

Function makepalindrome:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 7, Position 2 = 30
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 30
Branch analysis from position: 8
2 jumps found. (Code = 46) Position 1 = 15, Position 2 = 17
Branch analysis from position: 15
2 jumps found. (Code = 47) Position 1 = 18, Position 2 = 24
Branch analysis from position: 18
2 jumps found. (Code = 46) Position 1 = 20, Position 2 = 23
Branch analysis from position: 20
2 jumps found. (Code = 43) Position 1 = 26, Position 2 = 29
Branch analysis from position: 26
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 29
Branch analysis from position: 23
Branch analysis from position: 24
Branch analysis from position: 17
Branch analysis from position: 30
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 30
filename:       /in/CuLAu
function name:  makePalindrome
number of ops:  33
compiled vars:  !0 = $word, !1 = $result, !2 = $chars, !3 = $char, !4 = $index, !5 = $ascii
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    5     1        ASSIGN                                                   !1, 0
    7     2        INIT_FCALL                                               'str_split'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $7      
          5        ASSIGN                                                   !2, $7
    9     6      > FE_RESET_R                                       $9      !2, ->30
          7    > > FE_FETCH_R                                       ~10     $9, !3, ->30
          8    >   ASSIGN                                                   !4, ~10
   11     9        INIT_FCALL                                               'ord'
         10        SEND_VAR                                                 !3
         11        DO_ICALL                                         $12     
         12        ASSIGN                                                   !5, $12
   13    13        IS_SMALLER_OR_EQUAL                              ~14     97, !5
         14      > JMPZ_EX                                          ~14     ~14, ->17
         15    >   IS_EQUAL                                         ~15     !4, 0
         16        BOOL                                             ~14     ~15
         17    > > JMPNZ_EX                                         ~14     ~14, ->24
         18    >   IS_SMALLER_OR_EQUAL                              ~16     !5, 122
         19      > JMPZ_EX                                          ~16     ~16, ->23
         20    >   COUNT                                            ~17     !2
         21        IS_EQUAL                                         ~18     !4, ~17
         22        BOOL                                             ~16     ~18
         23    >   BOOL                                             ~14     ~16
         24    >   BOOL_NOT                                         ~19     ~14
         25      > JMPZ                                                     ~19, ->29
   15    26    >   SUB                                              ~20     !5, 97
         27        ADD                                              ~21     ~20, 1
         28        ASSIGN_OP                                     1          !1, ~21
    9    29    > > JMP                                                      ->7
         30    >   FE_FREE                                                  $9
   20    31      > RETURN                                                   !1
   21    32*     > RETURN                                                   null

End of function makepalindrome

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
168.4 ms | 1403 KiB | 18 Q