Posted By

assbach on 12/10/06


Tagged

random String


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

vali29
sb_01


random string


 / Published in: PHP
 

  1. $len = 16;
  2. $base='ABCDEFGHKLMNOPQRSTWXYZabcdefghjkmnpqrstwxyz123456789';
  3. $max=strlen($base)-1;
  4. $activatecode='';
  5. mt_srand((double)microtime()*1000000);
  6. while (strlen($activatecode)<$len+1)
  7. $activatecode.=$base{mt_rand(0,$max)};
  8.  
  9. echo $activatecode;

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: assbach on July 26, 2007

easier: $r = strtoupper(md5(time()));

You need to login to post a comment.