3v4l.org

run code in 300+ PHP versions simultaneously
<?php $res = 680131659347; define('ALPHABET', 'acdegilmnoprstuw'); echo get_hash(ALPHABET, 'leepadg'), PHP_EOL; function get_hash($alphabet, $string) { $h = 7; $len = strlen($string); for($i = 0; $i < $len; $i++) { $h = ($h * 37 + strpos($alphabet, $string[$i])); } return $h; } function unhash($alphabet, $hash) { $result = ''; $len = strlen($letters); while ($res > 7) { for ($i = 0; $i < $len; $i++) { $newres = ($res - $i) / 37; if (is_int($newres)) { $result .= $letters[$i]; $res = $newres; break; } } return strrev($result); } }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Dl9mE
function name:  (null)
number of ops:  13
compiled vars:  !0 = $res
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 680131659347
    4     1        INIT_FCALL                                               'define'
          2        SEND_VAL                                                 'ALPHABET'
          3        SEND_VAL                                                 'acdegilmnoprstuw'
          4        DO_ICALL                                                 
    6     5        INIT_FCALL_BY_NAME                                       'get_hash'
          6        FETCH_CONSTANT                                   ~3      'ALPHABET'
          7        SEND_VAL_EX                                              ~3
          8        SEND_VAL_EX                                              'leepadg'
          9        DO_FCALL                                      0  $4      
         10        ECHO                                                     $4
         11        ECHO                                                     '%0A'
   32    12      > RETURN                                                   1

Function get_hash:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
2 jumps found. (Code = 44) Position 1 = 18, Position 2 = 7
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
2 jumps found. (Code = 44) Position 1 = 18, Position 2 = 7
Branch analysis from position: 18
Branch analysis from position: 7
filename:       /in/Dl9mE
function name:  get_hash
number of ops:  20
compiled vars:  !0 = $alphabet, !1 = $string, !2 = $h, !3 = $len, !4 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    9     2        ASSIGN                                                   !2, 7
   10     3        STRLEN                                           ~6      !1
          4        ASSIGN                                                   !3, ~6
   11     5        ASSIGN                                                   !4, 0
          6      > JMP                                                      ->16
   12     7    >   MUL                                              ~9      !2, 37
          8        INIT_FCALL                                               'strpos'
          9        SEND_VAR                                                 !0
         10        FETCH_DIM_R                                      ~10     !1, !4
         11        SEND_VAL                                                 ~10
         12        DO_ICALL                                         $11     
         13        ADD                                              ~12     ~9, $11
         14        ASSIGN                                                   !2, ~12
   11    15        PRE_INC                                                  !4
         16    >   IS_SMALLER                                               !4, !3
         17      > JMPNZ                                                    ~15, ->7
   14    18    > > RETURN                                                   !2
   15    19*     > RETURN                                                   null

End of function get_hash

Function unhash:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
2 jumps found. (Code = 44) Position 1 = 26, Position 2 = 6
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 18
Branch analysis from position: 18
2 jumps found. (Code = 44) Position 1 = 20, Position 2 = 8
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 17
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
Branch analysis from position: 17
2 jumps found. (Code = 44) Position 1 = 20, Position 2 = 8
Branch analysis from position: 20
Branch analysis from position: 8
filename:       /in/Dl9mE
function name:  unhash
number of ops:  27
compiled vars:  !0 = $alphabet, !1 = $hash, !2 = $result, !3 = $len, !4 = $letters, !5 = $i, !6 = $newres, !7 = $res
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   18     2        ASSIGN                                                   !2, ''
   19     3        STRLEN                                           ~9      !4
          4        ASSIGN                                                   !3, ~9
   20     5      > JMP                                                      ->24
   21     6    >   ASSIGN                                                   !5, 0
          7      > JMP                                                      ->18
   22     8    >   SUB                                              ~12     !7, !5
          9        DIV                                              ~13     ~12, 37
         10        ASSIGN                                                   !6, ~13
   23    11        TYPE_CHECK                                   16          !6
         12      > JMPZ                                                     ~15, ->17
   24    13    >   FETCH_DIM_R                                      ~16     !4, !5
         14        ASSIGN_OP                                     8          !2, ~16
   25    15        ASSIGN                                                   !7, !6
   26    16      > JMP                                                      ->20
   21    17    >   PRE_INC                                                  !5
         18    >   IS_SMALLER                                               !5, !3
         19      > JMPNZ                                                    ~20, ->8
   30    20    >   INIT_FCALL                                               'strrev'
         21        SEND_VAR                                                 !2
         22        DO_ICALL                                         $21     
         23      > RETURN                                                   $21
   20    24    >   IS_SMALLER                                               7, !7
         25      > JMPNZ                                                    ~22, ->6
   32    26    > > RETURN                                                   null

End of function unhash

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
172.88 ms | 1400 KiB | 19 Q