3v4l.org

run code in 300+ PHP versions simultaneously
<?php function base26($value) { $name = ''; for ($exponent = 0; pow(26, $exponent) <= $value; $exponent++) { $digitWeight = intval(pow(26, $exponent)); $remainder = $value % intval(pow(26, $exponent + 1)); $digitValue = intval($remainder / $digitWeight); if (0 == $digitValue) { $digitValue = 26; } $ascii = 64 + $digitValue; $name = chr($ascii) . $name; echo sprintf("digitValue: %d, ascii: %d, value: %d, remainder: %d\n", $digitValue, $ascii, $value, $remainder); $value -= $digitValue; } 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/U0lF9
function name:  (null)
number of ops:  24
compiled vars:  !0 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     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
   20    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 = 41
Branch analysis from position: 41
2 jumps found. (Code = 44) Position 1 = 47, Position 2 = 4
Branch analysis from position: 47
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 23, Position 2 = 24
Branch analysis from position: 23
2 jumps found. (Code = 44) Position 1 = 47, Position 2 = 4
Branch analysis from position: 47
Branch analysis from position: 4
Branch analysis from position: 24
filename:       /in/U0lF9
function name:  base26
number of ops:  49
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                                                   !2, 0
          3      > JMP                                                      ->41
    5     4    >   INIT_FCALL                                               'pow'
          5        SEND_VAL                                                 26
          6        SEND_VAR                                                 !2
          7        DO_ICALL                                         $9      
          8        CAST                                          4  ~10     $9
          9        ASSIGN                                                   !3, ~10
    6    10        INIT_FCALL                                               'pow'
         11        SEND_VAL                                                 26
         12        ADD                                              ~12     !2, 1
         13        SEND_VAL                                                 ~12
         14        DO_ICALL                                         $13     
         15        CAST                                          4  ~14     $13
         16        MOD                                              ~15     !0, ~14
         17        ASSIGN                                                   !4, ~15
    7    18        DIV                                              ~17     !4, !3
         19        CAST                                          4  ~18     ~17
         20        ASSIGN                                                   !5, ~18
    8    21        IS_EQUAL                                                 !5, 0
         22      > JMPZ                                                     ~20, ->24
    9    23    >   ASSIGN                                                   !5, 26
   11    24    >   ADD                                              ~22     64, !5
         25        ASSIGN                                                   !6, ~22
   12    26        INIT_FCALL                                               'chr'
         27        SEND_VAR                                                 !6
         28        DO_ICALL                                         $24     
         29        CONCAT                                           ~25     $24, !1
         30        ASSIGN                                                   !1, ~25
   13    31        INIT_FCALL                                               'sprintf'
         32        SEND_VAL                                                 'digitValue%3A+%25d%2C+ascii%3A+%25d%2C+value%3A+%25d%2C+remainder%3A+%25d%0A'
         33        SEND_VAR                                                 !5
         34        SEND_VAR                                                 !6
         35        SEND_VAR                                                 !0
         36        SEND_VAR                                                 !4
         37        DO_ICALL                                         $27     
         38        ECHO                                                     $27
   14    39        ASSIGN_OP                                     2          !0, !5
    4    40        PRE_INC                                                  !2
         41    >   INIT_FCALL                                               'pow'
         42        SEND_VAL                                                 26
         43        SEND_VAR                                                 !2
         44        DO_ICALL                                         $30     
         45        IS_SMALLER_OR_EQUAL                                      $30, !0
         46      > JMPNZ                                                    ~31, ->4
   16    47    > > RETURN                                                   !1
   17    48*     > RETURN                                                   null

End of function base26

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.25 ms | 1394 KiB | 21 Q