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); $ascii = 64 + $digitValue; $name = chr($ascii) . $name; echo sprintf("digitValue: %d, ascii: %d, value: %d, remainder: %d\n", $digitValue, $ascii, $value, $remainder); $value -= $remainder; } return $name; } for ($i = 1; $i < 28; $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
1 jumps found. (Code = 62) Position 1 = -2
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/X6F1b
function name:  (null)
number of ops:  13
compiled vars:  !0 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     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
         12    > > RETURN                                                   1

Function base26:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 38
Branch analysis from position: 38
2 jumps found. (Code = 44) Position 1 = 44, Position 2 = 4
Branch analysis from position: 44
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 4
2 jumps found. (Code = 44) Position 1 = 44, Position 2 = 4
Branch analysis from position: 44
Branch analysis from position: 4
filename:       /in/X6F1b
function name:  base26
number of ops:  46
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                                                      ->38
    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        ADD                                              ~20     64, !5
         22        ASSIGN                                                   !6, ~20
    9    23        INIT_FCALL                                               'chr'
         24        SEND_VAR                                                 !6
         25        DO_ICALL                                         $22     
         26        CONCAT                                           ~23     $22, !1
         27        ASSIGN                                                   !1, ~23
   10    28        INIT_FCALL                                               'sprintf'
         29        SEND_VAL                                                 'digitValue%3A+%25d%2C+ascii%3A+%25d%2C+value%3A+%25d%2C+remainder%3A+%25d%0A'
         30        SEND_VAR                                                 !5
         31        SEND_VAR                                                 !6
         32        SEND_VAR                                                 !0
         33        SEND_VAR                                                 !4
         34        DO_ICALL                                         $25     
         35        ECHO                                                     $25
   11    36        ASSIGN_OP                                     2          !0, !4
    4    37        PRE_INC                                                  !2
         38    >   INIT_FCALL                                               'pow'
         39        SEND_VAL                                                 26
         40        SEND_VAR                                                 !2
         41        DO_ICALL                                         $28     
         42        IS_SMALLER_OR_EQUAL                                      $28, !0
         43      > JMPNZ                                                    ~29, ->4
   13    44    > > RETURN                                                   !1
   14    45*     > RETURN                                                   null

End of function base26

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.66 ms | 1403 KiB | 20 Q