3v4l.org

run code in 300+ PHP versions simultaneously
<?php echo alphaID('B3333V', true, 6, '3gmgkvj0jw8hrkcnu'); function alphaID($in, $to_num = false, $pad_up = false, $pass_key = null) { $out = ''; $index = 'abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'; $base = strlen($index); if ($pass_key !== null) { // Although this function's purpose is to just make the // ID short - and not so much secure, // with this patch by Simon Franz (http://blog.snaky.org/) // you can optionally supply a password to make it harder // to calculate the corresponding numeric ID $i = str_split($index); $pass_hash = hash('sha256',$pass_key); $pass_hash = (strlen($pass_hash) < strlen($index) ? hash('sha512', $pass_key) : $pass_hash); $pass_hash = substr($pass_hash, 0, strlen($index)); $p = str_split($pass_hash); array_multisort($p, SORT_DESC, $i); $index = implode($i); } if ($to_num) { // Digital number <<-- alphabet letter code $len = strlen($in) - 1; for ($t = $len; $t >= 0; $t--) { $bcp = bcpow($base, $len - $t); $out = $out + strpos($index, substr($in, $t, 1)) * $bcp; } if (is_numeric($pad_up)) { $pad_up--; if ($pad_up > 0) { $out -= pow($base, $pad_up); } } } else { // Digital number -->> alphabet letter code if (is_numeric($pad_up)) { $pad_up--; if ($pad_up > 0) { $in += pow($base, $pad_up); } } for ($t = ($in != 0 ? floor(log($in, $base)) : 0); $t >= 0; $t--) { $bcp = bcpow($base, $t); $a = floor($in / $bcp) % $base; $out = $out . substr($index, $a, 1); $in = $in - ($a * $bcp); } } return $out; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fKK50
function name:  (null)
number of ops:  8
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL_BY_NAME                                       'alphaID'
          1        SEND_VAL_EX                                              'B3333V'
          2        SEND_VAL_EX                                              <true>
          3        SEND_VAL_EX                                              6
          4        SEND_VAL_EX                                              '3gmgkvj0jw8hrkcnu'
          5        DO_FCALL                                      0  $0      
          6        ECHO                                                     $0
   52     7      > RETURN                                                   1

Function alphaid:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 51
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 23, Position 2 = 29
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 30
Branch analysis from position: 30
2 jumps found. (Code = 43) Position 1 = 52, Position 2 = 91
Branch analysis from position: 52
1 jumps found. (Code = 42) Position 1 = 76
Branch analysis from position: 76
2 jumps found. (Code = 44) Position 1 = 78, Position 2 = 57
Branch analysis from position: 78
2 jumps found. (Code = 43) Position 1 = 82, Position 2 = 90
Branch analysis from position: 82
2 jumps found. (Code = 43) Position 1 = 85, Position 2 = 90
Branch analysis from position: 85
1 jumps found. (Code = 42) Position 1 = 141
Branch analysis from position: 141
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 90
Branch analysis from position: 90
Branch analysis from position: 57
2 jumps found. (Code = 44) Position 1 = 78, Position 2 = 57
Branch analysis from position: 78
Branch analysis from position: 57
Branch analysis from position: 91
2 jumps found. (Code = 43) Position 1 = 95, Position 2 = 103
Branch analysis from position: 95
2 jumps found. (Code = 43) Position 1 = 98, Position 2 = 103
Branch analysis from position: 98
2 jumps found. (Code = 43) Position 1 = 105, Position 2 = 114
Branch analysis from position: 105
1 jumps found. (Code = 42) Position 1 = 115
Branch analysis from position: 115
1 jumps found. (Code = 42) Position 1 = 139
Branch analysis from position: 139
2 jumps found. (Code = 44) Position 1 = 141, Position 2 = 117
Branch analysis from position: 141
Branch analysis from position: 117
2 jumps found. (Code = 44) Position 1 = 141, Position 2 = 117
Branch analysis from position: 141
Branch analysis from position: 117
Branch analysis from position: 114
1 jumps found. (Code = 42) Position 1 = 139
Branch analysis from position: 139
Branch analysis from position: 103
Branch analysis from position: 103
Branch analysis from position: 29
2 jumps found. (Code = 43) Position 1 = 52, Position 2 = 91
Branch analysis from position: 52
Branch analysis from position: 91
Branch analysis from position: 51
filename:       /in/fKK50
function name:  alphaID
number of ops:  143
compiled vars:  !0 = $in, !1 = $to_num, !2 = $pad_up, !3 = $pass_key, !4 = $out, !5 = $index, !6 = $base, !7 = $i, !8 = $pass_hash, !9 = $p, !10 = $len, !11 = $t, !12 = $bcp, !13 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      <false>
          2        RECV_INIT                                        !2      <false>
          3        RECV_INIT                                        !3      null
    6     4        ASSIGN                                                   !4, ''
    7     5        ASSIGN                                                   !5, 'abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'
    8     6        STRLEN                                           ~16     !5
          7        ASSIGN                                                   !6, ~16
    9     8        TYPE_CHECK                                  1020          !3
          9      > JMPZ                                                     ~18, ->51
   15    10    >   INIT_FCALL                                               'str_split'
         11        SEND_VAR                                                 !5
         12        DO_ICALL                                         $19     
         13        ASSIGN                                                   !7, $19
   16    14        INIT_FCALL                                               'hash'
         15        SEND_VAL                                                 'sha256'
         16        SEND_VAR                                                 !3
         17        DO_ICALL                                         $21     
         18        ASSIGN                                                   !8, $21
   17    19        STRLEN                                           ~23     !8
         20        STRLEN                                           ~24     !5
         21        IS_SMALLER                                               ~23, ~24
         22      > JMPZ                                                     ~25, ->29
         23    >   INIT_FCALL                                               'hash'
         24        SEND_VAL                                                 'sha512'
         25        SEND_VAR                                                 !3
         26        DO_ICALL                                         $26     
         27        QM_ASSIGN                                        ~27     $26
         28      > JMP                                                      ->30
         29    >   QM_ASSIGN                                        ~27     !8
         30    >   ASSIGN                                                   !8, ~27
   18    31        INIT_FCALL                                               'substr'
         32        SEND_VAR                                                 !8
         33        SEND_VAL                                                 0
         34        STRLEN                                           ~29     !5
         35        SEND_VAL                                                 ~29
         36        DO_ICALL                                         $30     
         37        ASSIGN                                                   !8, $30
   19    38        INIT_FCALL                                               'str_split'
         39        SEND_VAR                                                 !8
         40        DO_ICALL                                         $32     
         41        ASSIGN                                                   !9, $32
   20    42        INIT_FCALL                                               'array_multisort'
         43        SEND_REF                                                 !9
         44        SEND_VAL                                                 3
         45        SEND_REF                                                 !7
         46        DO_ICALL                                                 
   21    47        INIT_FCALL                                               'implode'
         48        SEND_VAR                                                 !7
         49        DO_ICALL                                         $35     
         50        ASSIGN                                                   !5, $35
   23    51    > > JMPZ                                                     !1, ->91
   25    52    >   STRLEN                                           ~37     !0
         53        SUB                                              ~38     ~37, 1
         54        ASSIGN                                                   !10, ~38
   26    55        ASSIGN                                                   !11, !10
         56      > JMP                                                      ->76
   27    57    >   INIT_FCALL_BY_NAME                                       'bcpow'
         58        SEND_VAR_EX                                              !6
         59        SUB                                              ~41     !10, !11
         60        SEND_VAL_EX                                              ~41
         61        DO_FCALL                                      0  $42     
         62        ASSIGN                                                   !12, $42
   28    63        INIT_FCALL                                               'strpos'
         64        SEND_VAR                                                 !5
         65        INIT_FCALL                                               'substr'
         66        SEND_VAR                                                 !0
         67        SEND_VAR                                                 !11
         68        SEND_VAL                                                 1
         69        DO_ICALL                                         $44     
         70        SEND_VAR                                                 $44
         71        DO_ICALL                                         $45     
         72        MUL                                              ~46     !12, $45
         73        ADD                                              ~47     !4, ~46
         74        ASSIGN                                                   !4, ~47
   26    75        PRE_DEC                                                  !11
         76    >   IS_SMALLER_OR_EQUAL                                      0, !11
         77      > JMPNZ                                                    ~50, ->57
   30    78    >   INIT_FCALL                                               'is_numeric'
         79        SEND_VAR                                                 !2
         80        DO_ICALL                                         $51     
         81      > JMPZ                                                     $51, ->90
   31    82    >   PRE_DEC                                                  !2
   32    83        IS_SMALLER                                               0, !2
         84      > JMPZ                                                     ~53, ->90
   33    85    >   INIT_FCALL                                               'pow'
         86        SEND_VAR                                                 !6
         87        SEND_VAR                                                 !2
         88        DO_ICALL                                         $54     
         89        ASSIGN_OP                                     2          !4, $54
         90    > > JMP                                                      ->141
   38    91    >   INIT_FCALL                                               'is_numeric'
         92        SEND_VAR                                                 !2
         93        DO_ICALL                                         $56     
         94      > JMPZ                                                     $56, ->103
   39    95    >   PRE_DEC                                                  !2
   40    96        IS_SMALLER                                               0, !2
         97      > JMPZ                                                     ~58, ->103
   41    98    >   INIT_FCALL                                               'pow'
         99        SEND_VAR                                                 !6
        100        SEND_VAR                                                 !2
        101        DO_ICALL                                         $59     
        102        ASSIGN_OP                                     1          !0, $59
   44   103    >   IS_NOT_EQUAL                                             !0, 0
        104      > JMPZ                                                     ~61, ->114
        105    >   INIT_FCALL                                               'floor'
        106        INIT_FCALL                                               'log'
        107        SEND_VAR                                                 !0
        108        SEND_VAR                                                 !6
        109        DO_ICALL                                         $62     
        110        SEND_VAR                                                 $62
        111        DO_ICALL                                         $63     
        112        QM_ASSIGN                                        ~64     $63
        113      > JMP                                                      ->115
        114    >   QM_ASSIGN                                        ~64     0
        115    >   ASSIGN                                                   !11, ~64
        116      > JMP                                                      ->139
   45   117    >   INIT_FCALL_BY_NAME                                       'bcpow'
        118        SEND_VAR_EX                                              !6
        119        SEND_VAR_EX                                              !11
        120        DO_FCALL                                      0  $66     
        121        ASSIGN                                                   !12, $66
   46   122        INIT_FCALL                                               'floor'
        123        DIV                                              ~68     !0, !12
        124        SEND_VAL                                                 ~68
        125        DO_ICALL                                         $69     
        126        MOD                                              ~70     $69, !6
        127        ASSIGN                                                   !13, ~70
   47   128        INIT_FCALL                                               'substr'
        129        SEND_VAR                                                 !5
        130        SEND_VAR                                                 !13
        131        SEND_VAL                                                 1
        132        DO_ICALL                                         $72     
        133        CONCAT                                           ~73     !4, $72
        134        ASSIGN                                                   !4, ~73
   48   135        MUL                                              ~75     !13, !12
        136        SUB                                              ~76     !0, ~75
        137        ASSIGN                                                   !0, ~76
   44   138        PRE_DEC                                                  !11
        139    >   IS_SMALLER_OR_EQUAL                                      0, !11
        140      > JMPNZ                                                    ~79, ->117
   51   141    > > RETURN                                                   !4
   52   142*     > RETURN                                                   null

End of function alphaid

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
177.5 ms | 1408 KiB | 36 Q