3v4l.org

run code in 500+ PHP versions simultaneously
<?php generate(); // FUNCTION function generate() { $digilist = "0123456789ABCDEFGHJKLMNPQRTUVWXY"; //now we generate a new random ID number using the substrings of the digitList string above for( $i = 0; $i < 100; $i++) { $three_chars = NULL; $three_chars .= substr( $digilist, rand( 1, 9 ), 1 ); $three_chars .= substr( $digilist, rand( 10, 31 ), 1 ); $three_chars .= substr( $digilist, rand( 10, 31 ), 1 ); if ($i < 10) { $three_chars .= '0'; $three_chars .= $i; } else { $three_chars .= $i; } $id = $three_chars; $key = get_key( $id ); echo $id . ":" . $key . "\n"; } } function get_key( $id ) { $digilist = "0123456789ABCDEFGHJKLMNPQRTUVWXY"; //ok so now we need to generate an MD5 hash of our ID $hash = md5($id); //cycle through the hash 16 (length of key) times (in steps of 2 because each hex bytes is 2 digits long) $i = 0; $key = NULL; for ($i; $i < 32; $i+=2) { //here we convert the next hex value to an integer and perform a bitwise AND operation against '31' //31 is the highest substring value in our digit list. $nextdigit = hexdec(substr($hash, $i, 2)) & 31; //if 'i' is divisable by 8 (every 4 cycles) then we want to add "-" if ((($i % 8) == 0) && ($i > 0)) { $key .= "-".substr($digilist, $nextdigit, 1); } else { $key .= substr($digilist, $nextdigit, 1); } } return $key; }

Abusive script

This script was stopped while abusing our resources

Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/OCrQS
function name:  (null)
number of ops:  3
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    5     0  E >   INIT_FCALL_BY_NAME                                           'generate'
          1        DO_FCALL                                          0          
   62     2      > RETURN                                                       1

Function generate:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 41
Branch analysis from position: 41
2 jumps found. (Code = 44) Position 1 = 43, Position 2 = 3
Branch analysis from position: 43
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 27, Position 2 = 30
Branch analysis from position: 27
1 jumps found. (Code = 42) Position 1 = 31
Branch analysis from position: 31
2 jumps found. (Code = 44) Position 1 = 43, Position 2 = 3
Branch analysis from position: 43
Branch analysis from position: 3
Branch analysis from position: 30
2 jumps found. (Code = 44) Position 1 = 43, Position 2 = 3
Branch analysis from position: 43
Branch analysis from position: 3
filename:       /in/OCrQS
function name:  generate
number of ops:  44
compiled vars:  !0 = $digilist, !1 = $i, !2 = $three_chars, !3 = $id, !4 = $key
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   11     0  E >   ASSIGN                                                       !0, '0123456789ABCDEFGHJKLMNPQRTUVWXY'
   15     1        ASSIGN                                                       !1, 0
          2      > JMP                                                          ->41
   17     3    >   ASSIGN                                                       !2, null
   18     4        INIT_FCALL                                                   'rand'
          5        SEND_VAL                                                     1
          6        SEND_VAL                                                     9
          7        DO_ICALL                                             $8      
          8        FRAMELESS_ICALL_3                substr              ~9      !0, $8
          9        OP_DATA                                                      1
         10        ASSIGN_OP                                         8          !2, ~9
   19    11        INIT_FCALL                                                   'rand'
         12        SEND_VAL                                                     10
         13        SEND_VAL                                                     31
         14        DO_ICALL                                             $11     
         15        FRAMELESS_ICALL_3                substr              ~12     !0, $11
         16        OP_DATA                                                      1
         17        ASSIGN_OP                                         8          !2, ~12
   20    18        INIT_FCALL                                                   'rand'
         19        SEND_VAL                                                     10
         20        SEND_VAL                                                     31
         21        DO_ICALL                                             $14     
         22        FRAMELESS_ICALL_3                substr              ~15     !0, $14
         23        OP_DATA                                                      1
         24        ASSIGN_OP                                         8          !2, ~15
   21    25        IS_SMALLER                                                   !1, 10
         26      > JMPZ                                                         ~17, ->30
   23    27    >   ASSIGN_OP                                         8          !2, '0'
   24    28        ASSIGN_OP                                         8          !2, !1
   21    29      > JMP                                                          ->31
   28    30    >   ASSIGN_OP                                         8          !2, !1
   30    31    >   ASSIGN                                                       !3, !2
   31    32        INIT_FCALL_BY_NAME                                           'get_key'
         33        SEND_VAR_EX                                                  !3
         34        DO_FCALL                                          0  $22     
         35        ASSIGN                                                       !4, $22
   32    36        CONCAT                                               ~24     !3, '%3A'
         37        CONCAT                                               ~25     ~24, !4
         38        CONCAT                                               ~26     ~25, '%0A'
         39        ECHO                                                         ~26
   15    40        PRE_INC                                                      !1
         41    >   IS_SMALLER                                                   !1, 100
         42      > JMPNZ                                                        ~28, ->3
   34    43    > > RETURN                                                       null

End of function generate

Function get_key:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 31
Branch analysis from position: 31
2 jumps found. (Code = 44) Position 1 = 33, Position 2 = 9
Branch analysis from position: 33
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
2 jumps found. (Code = 46) Position 1 = 19, Position 2 = 21
Branch analysis from position: 19
2 jumps found. (Code = 43) Position 1 = 22, Position 2 = 27
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 30
Branch analysis from position: 30
2 jumps found. (Code = 44) Position 1 = 33, Position 2 = 9
Branch analysis from position: 33
Branch analysis from position: 9
Branch analysis from position: 27
2 jumps found. (Code = 44) Position 1 = 33, Position 2 = 9
Branch analysis from position: 33
Branch analysis from position: 9
Branch analysis from position: 21
filename:       /in/OCrQS
function name:  get_key
number of ops:  35
compiled vars:  !0 = $id, !1 = $digilist, !2 = $hash, !3 = $i, !4 = $key, !5 = $nextdigit
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   36     0  E >   RECV                                                 !0      
   38     1        ASSIGN                                                       !1, '0123456789ABCDEFGHJKLMNPQRTUVWXY'
   40     2        INIT_FCALL                                                   'md5'
          3        SEND_VAR                                                     !0
          4        DO_ICALL                                             $7      
          5        ASSIGN                                                       !2, $7
   43     6        ASSIGN                                                       !3, 0
   44     7        ASSIGN                                                       !4, null
   45     8      > JMP                                                          ->31
   49     9    >   INIT_FCALL                                                   'hexdec'
         10        FRAMELESS_ICALL_3                substr              ~11     !2, !3
         11        OP_DATA                                                      2
         12        SEND_VAL                                                     ~11
         13        DO_ICALL                                             $12     
         14        BW_AND                                               ~13     $12, 31
         15        ASSIGN                                                       !5, ~13
   52    16        MOD                                                  ~15     !3, 8
         17        IS_EQUAL                                             ~16     ~15, 0
         18      > JMPZ_EX                                              ~16     ~16, ->21
         19    >   IS_SMALLER                                           ~17     0, !3
         20        BOOL                                                 ~16     ~17
         21    > > JMPZ                                                         ~16, ->27
   54    22    >   FRAMELESS_ICALL_3                substr              ~18     !1, !5
         23        OP_DATA                                                      1
         24        CONCAT                                               ~19     '-', ~18
         25        ASSIGN_OP                                         8          !4, ~19
   52    26      > JMP                                                          ->30
   58    27    >   FRAMELESS_ICALL_3                substr              ~21     !1, !5
         28        OP_DATA                                                      1
         29        ASSIGN_OP                                         8          !4, ~21
   45    30    >   ASSIGN_OP                                         1          !3, 2
         31    >   IS_SMALLER                                                   !3, 32
         32      > JMPNZ                                                        ~24, ->9
   61    33    > > RETURN                                                       !4
   62    34*     > RETURN                                                       null

End of function get_key

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
166.11 ms | 2463 KiB | 16 Q