evCreateRandomString | generates a random alphanumeric string


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



Copy this code and paste it in your HTML
  1. // name: evCreateRandomString
  2. // version: v0.1
  3. // description: genera un string alfanumérico de X caracteres
  4.  
  5. function evCreateRandomString( $numChars = 6 ) {
  6.  
  7. $chars = "abcdefghijkmnopqrstuvwxyz023456789";
  8. srand((double)microtime()*1000000);
  9. $i = 0;
  10.  
  11. $string = '' ;
  12.  
  13. while ( $i <= $numChars ) {
  14. $num = rand() % 33;
  15. $tmp = substr($chars, $num, 1);
  16. $pass = $pass . $tmp;
  17. $i++;
  18. }
  19.  
  20. return $pass;
  21.  
  22. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.