3v4l.org

run code in 300+ PHP versions simultaneously
<?php // EXAMPLE USAGE $array = generate(); echo $array[0]; echo "<br />"; echo $array[1]; // FUNCTION function generate() { $digilist = "0123456789ABCDEFGHJKLMNPQRTUVWXY"; //now we generate a new random ID number using the substrings of the digitList string above $id = NULL; $id .= substr($digilist, rand(9, 9), 1); //random number $id .= substr($digilist, rand(21, 21), 1); //then a letter $id .= substr($digilist, rand(13, 13), 1); //another letter $id .= substr($digilist, rand(2, 9), 1); //a number $id .= substr($digilist, rand(6, 6), 1); //and finally another number - simple :D //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); } } $array = array($id, $key); //return return $array; } ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/dR6uZ
function name:  (null)
number of ops:  9
compiled vars:  !0 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL_BY_NAME                                       'generate'
          1        DO_FCALL                                      0  $1      
          2        ASSIGN                                                   !0, $1
    4     3        FETCH_DIM_R                                      ~3      !0, 0
          4        ECHO                                                     ~3
    5     5        ECHO                                                     '%3Cbr+%2F%3E'
    6     6        FETCH_DIM_R                                      ~4      !0, 1
          7        ECHO                                                     ~4
   49     8      > RETURN                                                   1

Function generate:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 90
Branch analysis from position: 90
2 jumps found. (Code = 44) Position 1 = 92, Position 2 = 59
Branch analysis from position: 92
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 59
2 jumps found. (Code = 46) Position 1 = 72, Position 2 = 74
Branch analysis from position: 72
2 jumps found. (Code = 43) Position 1 = 75, Position 2 = 83
Branch analysis from position: 75
1 jumps found. (Code = 42) Position 1 = 89
Branch analysis from position: 89
2 jumps found. (Code = 44) Position 1 = 92, Position 2 = 59
Branch analysis from position: 92
Branch analysis from position: 59
Branch analysis from position: 83
2 jumps found. (Code = 44) Position 1 = 92, Position 2 = 59
Branch analysis from position: 92
Branch analysis from position: 59
Branch analysis from position: 74
filename:       /in/dR6uZ
function name:  generate
number of ops:  97
compiled vars:  !0 = $digilist, !1 = $id, !2 = $hash, !3 = $i, !4 = $key, !5 = $nextdigit, !6 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   ASSIGN                                                   !0, '0123456789ABCDEFGHJKLMNPQRTUVWXY'
   15     1        ASSIGN                                                   !1, null
   16     2        INIT_FCALL                                               'substr'
          3        SEND_VAR                                                 !0
          4        INIT_FCALL                                               'rand'
          5        SEND_VAL                                                 9
          6        SEND_VAL                                                 9
          7        DO_ICALL                                         $9      
          8        SEND_VAR                                                 $9
          9        SEND_VAL                                                 1
         10        DO_ICALL                                         $10     
         11        ASSIGN_OP                                     8          !1, $10
   17    12        INIT_FCALL                                               'substr'
         13        SEND_VAR                                                 !0
         14        INIT_FCALL                                               'rand'
         15        SEND_VAL                                                 21
         16        SEND_VAL                                                 21
         17        DO_ICALL                                         $12     
         18        SEND_VAR                                                 $12
         19        SEND_VAL                                                 1
         20        DO_ICALL                                         $13     
         21        ASSIGN_OP                                     8          !1, $13
   18    22        INIT_FCALL                                               'substr'
         23        SEND_VAR                                                 !0
         24        INIT_FCALL                                               'rand'
         25        SEND_VAL                                                 13
         26        SEND_VAL                                                 13
         27        DO_ICALL                                         $15     
         28        SEND_VAR                                                 $15
         29        SEND_VAL                                                 1
         30        DO_ICALL                                         $16     
         31        ASSIGN_OP                                     8          !1, $16
   19    32        INIT_FCALL                                               'substr'
         33        SEND_VAR                                                 !0
         34        INIT_FCALL                                               'rand'
         35        SEND_VAL                                                 2
         36        SEND_VAL                                                 9
         37        DO_ICALL                                         $18     
         38        SEND_VAR                                                 $18
         39        SEND_VAL                                                 1
         40        DO_ICALL                                         $19     
         41        ASSIGN_OP                                     8          !1, $19
   20    42        INIT_FCALL                                               'substr'
         43        SEND_VAR                                                 !0
         44        INIT_FCALL                                               'rand'
         45        SEND_VAL                                                 6
         46        SEND_VAL                                                 6
         47        DO_ICALL                                         $21     
         48        SEND_VAR                                                 $21
         49        SEND_VAL                                                 1
         50        DO_ICALL                                         $22     
         51        ASSIGN_OP                                     8          !1, $22
   23    52        INIT_FCALL                                               'md5'
         53        SEND_VAR                                                 !1
         54        DO_ICALL                                         $24     
         55        ASSIGN                                                   !2, $24
   26    56        ASSIGN                                                   !3, 0
   27    57        ASSIGN                                                   !4, null
   28    58      > JMP                                                      ->90
   32    59    >   INIT_FCALL                                               'hexdec'
         60        INIT_FCALL                                               'substr'
         61        SEND_VAR                                                 !2
         62        SEND_VAR                                                 !3
         63        SEND_VAL                                                 2
         64        DO_ICALL                                         $28     
         65        SEND_VAR                                                 $28
         66        DO_ICALL                                         $29     
         67        BW_AND                                           ~30     $29, 31
         68        ASSIGN                                                   !5, ~30
   35    69        MOD                                              ~32     !3, 8
         70        IS_EQUAL                                         ~33     ~32, 0
         71      > JMPZ_EX                                          ~33     ~33, ->74
         72    >   IS_SMALLER                                       ~34     0, !3
         73        BOOL                                             ~33     ~34
         74    > > JMPZ                                                     ~33, ->83
   37    75    >   INIT_FCALL                                               'substr'
         76        SEND_VAR                                                 !0
         77        SEND_VAR                                                 !5
         78        SEND_VAL                                                 1
         79        DO_ICALL                                         $35     
         80        CONCAT                                           ~36     '-', $35
         81        ASSIGN_OP                                     8          !4, ~36
         82      > JMP                                                      ->89
   41    83    >   INIT_FCALL                                               'substr'
         84        SEND_VAR                                                 !0
         85        SEND_VAR                                                 !5
         86        SEND_VAL                                                 1
         87        DO_ICALL                                         $38     
         88        ASSIGN_OP                                     8          !4, $38
   28    89    >   ASSIGN_OP                                     1          !3, 2
         90    >   IS_SMALLER                                               !3, 32
         91      > JMPNZ                                                    ~41, ->59
   45    92    >   INIT_ARRAY                                       ~42     !1
         93        ADD_ARRAY_ELEMENT                                ~42     !4
         94        ASSIGN                                                   !6, ~42
   47    95      > RETURN                                                   !6
   48    96*     > RETURN                                                   null

End of function generate

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.46 ms | 1404 KiB | 21 Q