Generate Random String (ids etc ..)


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. function generate_rand($l){
  2. $c= "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
  3. srand((double)microtime()*1000000);
  4. for($i=0; $i<$l; $i++) {
  5. $rand.= $c[rand()%strlen($c)];
  6. }
  7. return $rand;
  8. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.