3v4l.org

run code in 300+ PHP versions simultaneously
<?php function create_word(string $alphabet, int $index): string { $base = mb_strlen($alphabet); $fix = 1; $length = 1; foreach (range(1, $base) as $k) { $pow = pow($base, $k); if ($fix + $pow <= $index) { $fix += $pow; $length++; } else { break; } } $template = sprintf("%0{$length}d", base_convert($index - $fix, 10, $base)); $replace = implode('', range(0, $base)); return strtr($template, $replace, $alphabet); } for ($i = 1; $i <= 81; $i++) { echo $i . ' = '. create_word("abc", $i) . \PHP_EOL; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
2 jumps found. (Code = 44) Position 1 = 13, Position 2 = 2
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 2
2 jumps found. (Code = 44) Position 1 = 13, Position 2 = 2
Branch analysis from position: 13
Branch analysis from position: 2
filename:       /in/m12ke
function name:  (null)
number of ops:  14
compiled vars:  !0 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   ASSIGN                                                   !0, 1
          1      > JMP                                                      ->11
   24     2    >   CONCAT                                           ~2      !0, '+%3D+'
          3        INIT_FCALL                                               'create_word'
          4        SEND_VAL                                                 'abc'
          5        SEND_VAR                                                 !0
          6        DO_FCALL                                      0  $3      
          7        CONCAT                                           ~4      ~2, $3
          8        CONCAT                                           ~5      ~4, '%0A'
          9        ECHO                                                     ~5
   23    10        PRE_INC                                                  !0
         11    >   IS_SMALLER_OR_EQUAL                                      !0, 81
         12      > JMPNZ                                                    ~7, ->2
   25    13    > > RETURN                                                   1

Function create_word:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 13, Position 2 = 27
Branch analysis from position: 13
2 jumps found. (Code = 78) Position 1 = 14, Position 2 = 27
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 22, Position 2 = 25
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 27
Branch analysis from position: 27
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 27
Branch analysis from position: 27
filename:       /in/m12ke
function name:  create_word
number of ops:  60
compiled vars:  !0 = $alphabet, !1 = $index, !2 = $base, !3 = $fix, !4 = $length, !5 = $k, !6 = $pow, !7 = $template, !8 = $replace
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    5     2        INIT_FCALL                                               'mb_strlen'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $9      
          5        ASSIGN                                                   !2, $9
    6     6        ASSIGN                                                   !3, 1
    7     7        ASSIGN                                                   !4, 1
    8     8        INIT_FCALL                                               'range'
          9        SEND_VAL                                                 1
         10        SEND_VAR                                                 !2
         11        DO_ICALL                                         $13     
         12      > FE_RESET_R                                       $14     $13, ->27
         13    > > FE_FETCH_R                                               $14, !5, ->27
    9    14    >   INIT_FCALL                                               'pow'
         15        SEND_VAR                                                 !2
         16        SEND_VAR                                                 !5
         17        DO_ICALL                                         $15     
         18        ASSIGN                                                   !6, $15
   10    19        ADD                                              ~17     !3, !6
         20        IS_SMALLER_OR_EQUAL                                      ~17, !1
         21      > JMPZ                                                     ~18, ->25
   11    22    >   ASSIGN_OP                                     1          !3, !6
   12    23        PRE_INC                                                  !4
         24      > JMP                                                      ->26
   14    25    > > JMP                                                      ->27
    8    26    > > JMP                                                      ->13
         27    >   FE_FREE                                                  $14
   17    28        INIT_FCALL                                               'sprintf'
         29        ROPE_INIT                                     3  ~22     '%250'
         30        ROPE_ADD                                      1  ~22     ~22, !4
         31        ROPE_END                                      2  ~21     ~22, 'd'
         32        SEND_VAL                                                 ~21
         33        INIT_FCALL                                               'base_convert'
         34        SUB                                              ~24     !1, !3
         35        SEND_VAL                                                 ~24
         36        SEND_VAL                                                 10
         37        SEND_VAR                                                 !2
         38        DO_ICALL                                         $25     
         39        SEND_VAR                                                 $25
         40        DO_ICALL                                         $26     
         41        ASSIGN                                                   !7, $26
   18    42        INIT_FCALL                                               'implode'
         43        SEND_VAL                                                 ''
         44        INIT_FCALL                                               'range'
         45        SEND_VAL                                                 0
         46        SEND_VAR                                                 !2
         47        DO_ICALL                                         $28     
         48        SEND_VAR                                                 $28
         49        DO_ICALL                                         $29     
         50        ASSIGN                                                   !8, $29
   20    51        INIT_FCALL                                               'strtr'
         52        SEND_VAR                                                 !7
         53        SEND_VAR                                                 !8
         54        SEND_VAR                                                 !0
         55        DO_ICALL                                         $31     
         56        VERIFY_RETURN_TYPE                                       $31
         57      > RETURN                                                   $31
   21    58*       VERIFY_RETURN_TYPE                                       
         59*     > RETURN                                                   null

End of function create_word

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
142.54 ms | 1407 KiB | 28 Q