3v4l.org

run code in 300+ PHP versions simultaneously
<?php function base58_encode($num) { $alphabet = '123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ'; $base_count = strlen($alphabet); $encoded = ''; while ($num >= $base_count) { $div = $num / $base_count; $mod = ($num - ($base_count * intval($div))); $encoded = $alphabet[$mod] . $encoded; $num = intval($div); } if ($num) { $encoded = $alphabet[$num] . $encoded; } return $encoded; } function base58_decode($num) { $alphabet = '123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ'; $len = strlen($num); $decoded = 0; $multi = 1; for ($i = $len - 1; $i >= 0; $i--) { $decoded += $multi * strpos($alphabet, $num[$i]); $multi = $multi * strlen($alphabet); } return $decoded; } echo base58_decode("3jf"); echo base58_decode("Jkf");
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/T4PaL
function name:  (null)
number of ops:  9
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   36     0  E >   INIT_FCALL                                               'base58_decode'
          1        SEND_VAL                                                 '3jf'
          2        DO_FCALL                                      0  $0      
          3        ECHO                                                     $0
   37     4        INIT_FCALL                                               'base58_decode'
          5        SEND_VAL                                                 'Jkf'
          6        DO_FCALL                                      0  $1      
          7        ECHO                                                     $1
          8      > RETURN                                                   1

Function base58_encode:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
2 jumps found. (Code = 44) Position 1 = 19, Position 2 = 6
Branch analysis from position: 19
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 23
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
Branch analysis from position: 6
2 jumps found. (Code = 44) Position 1 = 19, Position 2 = 6
Branch analysis from position: 19
Branch analysis from position: 6
filename:       /in/T4PaL
function name:  base58_encode
number of ops:  25
compiled vars:  !0 = $num, !1 = $alphabet, !2 = $base_count, !3 = $encoded, !4 = $div, !5 = $mod
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    3     1        ASSIGN                                                   !1, '123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ'
    4     2        STRLEN                                           ~7      !1
          3        ASSIGN                                                   !2, ~7
    5     4        ASSIGN                                                   !3, ''
    7     5      > JMP                                                      ->17
    8     6    >   DIV                                              ~10     !0, !2
          7        ASSIGN                                                   !4, ~10
    9     8        CAST                                          4  ~12     !4
          9        MUL                                              ~13     !2, ~12
         10        SUB                                              ~14     !0, ~13
         11        ASSIGN                                                   !5, ~14
   10    12        FETCH_DIM_R                                      ~16     !1, !5
         13        CONCAT                                           ~17     ~16, !3
         14        ASSIGN                                                   !3, ~17
   11    15        CAST                                          4  ~19     !4
         16        ASSIGN                                                   !0, ~19
    7    17    >   IS_SMALLER_OR_EQUAL                                      !2, !0
         18      > JMPNZ                                                    ~21, ->6
   14    19    > > JMPZ                                                     !0, ->23
   15    20    >   FETCH_DIM_R                                      ~22     !1, !0
         21        CONCAT                                           ~23     ~22, !3
         22        ASSIGN                                                   !3, ~23
   18    23    > > RETURN                                                   !3
   19    24*     > RETURN                                                   null

End of function base58_encode

Function base58_decode:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
2 jumps found. (Code = 44) Position 1 = 22, Position 2 = 9
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
2 jumps found. (Code = 44) Position 1 = 22, Position 2 = 9
Branch analysis from position: 22
Branch analysis from position: 9
filename:       /in/T4PaL
function name:  base58_decode
number of ops:  24
compiled vars:  !0 = $num, !1 = $alphabet, !2 = $len, !3 = $decoded, !4 = $multi, !5 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   RECV                                             !0      
   22     1        ASSIGN                                                   !1, '123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ'
   23     2        STRLEN                                           ~7      !0
          3        ASSIGN                                                   !2, ~7
   24     4        ASSIGN                                                   !3, 0
   25     5        ASSIGN                                                   !4, 1
   27     6        SUB                                              ~11     !2, 1
          7        ASSIGN                                                   !5, ~11
          8      > JMP                                                      ->20
   28     9    >   INIT_FCALL                                               'strpos'
         10        SEND_VAR                                                 !1
         11        FETCH_DIM_R                                      ~13     !0, !5
         12        SEND_VAL                                                 ~13
         13        DO_ICALL                                         $14     
         14        MUL                                              ~15     !4, $14
         15        ASSIGN_OP                                     1          !3, ~15
   29    16        STRLEN                                           ~17     !1
         17        MUL                                              ~18     !4, ~17
         18        ASSIGN                                                   !4, ~18
   27    19        PRE_DEC                                                  !5
         20    >   IS_SMALLER_OR_EQUAL                                      0, !5
         21      > JMPNZ                                                    ~21, ->9
   32    22    > > RETURN                                                   !3
   33    23*     > RETURN                                                   null

End of function base58_decode

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
166.98 ms | 1403 KiB | 17 Q