3v4l.org

run code in 300+ PHP versions simultaneously
<?php function base26($value) { $name = ''; $value -= 1; for ($exponent = 0; pow(26, $exponent) < $value; $exponent++) { $digitWeight = intval(pow(26, $exponent)); $remainder = $value % intval(pow(26, $exponent + 1)); $digitValue = intval($remainder / $digitWeight); $digitValue += 1; $ascii = 64 + $digitValue; $name = chr($ascii) . $name; echo sprintf("digitValue: %d, ascii: %d, value: %d, remainder: %d\n", $digitValue, $ascii, $value, $remainder); $value = $value - $digitValue + 1; } return $name; } for ($i = 1; $i < 28; $i++) { echo $i . "->" . base26($i) . "\n"; } foreach (array(51, 52, 53, 77, 78, 79) as $i) { echo $i . "->" . base26($i) . "\n"; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
2 jumps found. (Code = 44) Position 1 = 12, Position 2 = 2
Branch analysis from position: 12
2 jumps found. (Code = 77) Position 1 = 13, Position 2 = 22
Branch analysis from position: 13
2 jumps found. (Code = 78) Position 1 = 14, Position 2 = 22
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 22
Branch analysis from position: 2
2 jumps found. (Code = 44) Position 1 = 12, Position 2 = 2
Branch analysis from position: 12
Branch analysis from position: 2
filename:       /in/vroup
function name:  (null)
number of ops:  24
compiled vars:  !0 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   ASSIGN                                                   !0, 1
          1      > JMP                                                      ->10
          2    >   CONCAT                                           ~2      !0, '-%3E'
          3        INIT_FCALL                                               'base26'
          4        SEND_VAR                                                 !0
          5        DO_FCALL                                      0  $3      
          6        CONCAT                                           ~4      ~2, $3
          7        CONCAT                                           ~5      ~4, '%0A'
          8        ECHO                                                     ~5
          9        PRE_INC                                                  !0
         10    >   IS_SMALLER                                               !0, 28
         11      > JMPNZ                                                    ~7, ->2
   19    12    > > FE_RESET_R                                       $8      <array>, ->22
         13    > > FE_FETCH_R                                               $8, !0, ->22
         14    >   CONCAT                                           ~9      !0, '-%3E'
         15        INIT_FCALL                                               'base26'
         16        SEND_VAR                                                 !0
         17        DO_FCALL                                      0  $10     
         18        CONCAT                                           ~11     ~9, $10
         19        CONCAT                                           ~12     ~11, '%0A'
         20        ECHO                                                     ~12
         21      > JMP                                                      ->13
         22    >   FE_FREE                                                  $8
         23      > RETURN                                                   1

Function base26:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 42
Branch analysis from position: 42
2 jumps found. (Code = 44) Position 1 = 48, Position 2 = 5
Branch analysis from position: 48
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
2 jumps found. (Code = 44) Position 1 = 48, Position 2 = 5
Branch analysis from position: 48
Branch analysis from position: 5
filename:       /in/vroup
function name:  base26
number of ops:  50
compiled vars:  !0 = $value, !1 = $name, !2 = $exponent, !3 = $digitWeight, !4 = $remainder, !5 = $digitValue, !6 = $ascii
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    3     1        ASSIGN                                                   !1, ''
    4     2        ASSIGN_OP                                     2          !0, 1
    5     3        ASSIGN                                                   !2, 0
          4      > JMP                                                      ->42
    6     5    >   INIT_FCALL                                               'pow'
          6        SEND_VAL                                                 26
          7        SEND_VAR                                                 !2
          8        DO_ICALL                                         $10     
          9        CAST                                          4  ~11     $10
         10        ASSIGN                                                   !3, ~11
    7    11        INIT_FCALL                                               'pow'
         12        SEND_VAL                                                 26
         13        ADD                                              ~13     !2, 1
         14        SEND_VAL                                                 ~13
         15        DO_ICALL                                         $14     
         16        CAST                                          4  ~15     $14
         17        MOD                                              ~16     !0, ~15
         18        ASSIGN                                                   !4, ~16
    8    19        DIV                                              ~18     !4, !3
         20        CAST                                          4  ~19     ~18
         21        ASSIGN                                                   !5, ~19
    9    22        ASSIGN_OP                                     1          !5, 1
   10    23        ADD                                              ~22     64, !5
         24        ASSIGN                                                   !6, ~22
   11    25        INIT_FCALL                                               'chr'
         26        SEND_VAR                                                 !6
         27        DO_ICALL                                         $24     
         28        CONCAT                                           ~25     $24, !1
         29        ASSIGN                                                   !1, ~25
   12    30        INIT_FCALL                                               'sprintf'
         31        SEND_VAL                                                 'digitValue%3A+%25d%2C+ascii%3A+%25d%2C+value%3A+%25d%2C+remainder%3A+%25d%0A'
         32        SEND_VAR                                                 !5
         33        SEND_VAR                                                 !6
         34        SEND_VAR                                                 !0
         35        SEND_VAR                                                 !4
         36        DO_ICALL                                         $27     
         37        ECHO                                                     $27
   13    38        SUB                                              ~28     !0, !5
         39        ADD                                              ~29     ~28, 1
         40        ASSIGN                                                   !0, ~29
    5    41        PRE_INC                                                  !2
         42    >   INIT_FCALL                                               'pow'
         43        SEND_VAL                                                 26
         44        SEND_VAR                                                 !2
         45        DO_ICALL                                         $32     
         46        IS_SMALLER                                               $32, !0
         47      > JMPNZ                                                    ~33, ->5
   15    48    > > RETURN                                                   !1
   16    49*     > RETURN                                                   null

End of function base26

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
168.31 ms | 1402 KiB | 21 Q