3v4l.org

run code in 300+ PHP versions simultaneously
<?php define('ALNUM_MAP', str_split('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789')); define('DIGIT_MAP', array_flip(ALNUM_MAP)); function numToAlnum($num) { return strtr($num, ALNUM_MAP); } function alnumToNum($alphaNum) { return strtr($alphaNum, DIGIT_MAP); } $ids = ['4440', '464426', '43304441302845', '262018191701180', '273381111186152545352']; foreach ($ids as $id) { $idLength = strlen($id); $alphaNum = numToAlnum($id); $alNumLength = strlen($alphaNum); $backToId = alnumToNum($alphaNum); var_export(['original' => $id, 'encoded' => $alphaNum, 'decoded' => $backToId, 'reduction' => $idLength - $alNumLength]); echo "\n---\n"; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 17, Position 2 = 40
Branch analysis from position: 17
2 jumps found. (Code = 78) Position 1 = 18, Position 2 = 40
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
Branch analysis from position: 40
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 40
filename:       /in/9EimB
function name:  (null)
number of ops:  42
compiled vars:  !0 = $ids, !1 = $id, !2 = $idLength, !3 = $alphaNum, !4 = $alNumLength, !5 = $backToId
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'define'
          1        SEND_VAL                                                 'ALNUM_MAP'
          2        INIT_FCALL                                               'str_split'
          3        SEND_VAL                                                 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'
          4        DO_ICALL                                         $6      
          5        SEND_VAR                                                 $6
          6        DO_ICALL                                                 
    4     7        INIT_FCALL                                               'define'
          8        SEND_VAL                                                 'DIGIT_MAP'
          9        INIT_FCALL                                               'array_flip'
         10        FETCH_CONSTANT                                   ~8      'ALNUM_MAP'
         11        SEND_VAL                                                 ~8
         12        DO_ICALL                                         $9      
         13        SEND_VAR                                                 $9
         14        DO_ICALL                                                 
   14    15        ASSIGN                                                   !0, <array>
   15    16      > FE_RESET_R                                       $12     !0, ->40
         17    > > FE_FETCH_R                                               $12, !1, ->40
   16    18    >   STRLEN                                           ~13     !1
         19        ASSIGN                                                   !2, ~13
   17    20        INIT_FCALL                                               'numtoalnum'
         21        SEND_VAR                                                 !1
         22        DO_FCALL                                      0  $15     
         23        ASSIGN                                                   !3, $15
   18    24        STRLEN                                           ~17     !3
         25        ASSIGN                                                   !4, ~17
   19    26        INIT_FCALL                                               'alnumtonum'
         27        SEND_VAR                                                 !3
         28        DO_FCALL                                      0  $19     
         29        ASSIGN                                                   !5, $19
   20    30        INIT_FCALL                                               'var_export'
         31        INIT_ARRAY                                       ~21     !1, 'original'
         32        ADD_ARRAY_ELEMENT                                ~21     !3, 'encoded'
         33        ADD_ARRAY_ELEMENT                                ~21     !5, 'decoded'
         34        SUB                                              ~22     !2, !4
         35        ADD_ARRAY_ELEMENT                                ~21     ~22, 'reduction'
         36        SEND_VAL                                                 ~21
         37        DO_ICALL                                                 
   21    38        ECHO                                                     '%0A---%0A'
   15    39      > JMP                                                      ->17
         40    >   FE_FREE                                                  $12
   22    41      > RETURN                                                   1

Function numtoalnum:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9EimB
function name:  numToAlnum
number of ops:  8
compiled vars:  !0 = $num
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
    7     1        INIT_FCALL                                               'strtr'
          2        SEND_VAR                                                 !0
          3        FETCH_CONSTANT                                   ~1      'ALNUM_MAP'
          4        SEND_VAL                                                 ~1
          5        DO_ICALL                                         $2      
          6      > RETURN                                                   $2
    8     7*     > RETURN                                                   null

End of function numtoalnum

Function alnumtonum:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9EimB
function name:  alnumToNum
number of ops:  8
compiled vars:  !0 = $alphaNum
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
   11     1        INIT_FCALL                                               'strtr'
          2        SEND_VAR                                                 !0
          3        FETCH_CONSTANT                                   ~1      'DIGIT_MAP'
          4        SEND_VAL                                                 ~1
          5        DO_ICALL                                         $2      
          6      > RETURN                                                   $2
   12     7*     > RETURN                                                   null

End of function alnumtonum

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
163.74 ms | 1402 KiB | 25 Q