Generate a random string.


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

This function returns a random string composed of the characters contained within the "$string" variable of the function.


Copy this code and paste it in your HTML
  1. <?php
  2. function randomString(){
  3. $string = "abcdefghijklmnopqrstuvwxyz0123456789";
  4. for($i=0;$i<25;$i++){
  5. $pos = rand(0,36);
  6. $str .= $string[$pos];
  7. }
  8. return $str
  9. }
  10. ?>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.