...as in...

<?
  // Could've been done with ASCII sets, but this way
  // you can easily tweak the eligible characters.
  $eligible='abcdefghijklmnopqrstuvwxyz0123456789';
  $pwdLen=8;
  $password='';
  for($i=0;$i<$pwdLen;$i++) {
    $password.=$eligible[rand(0,strlen($eligible))];
  }
  echo("Your new password: $password\n");
?>

Bogdan

David T-G wrote:
Shaun --

[No need to post twice...]

...and then Shaun said...
% % Hi,


Hi!


% % I need to generate a lowercase alphanumeric passwrord thats 8 characters
% long, has anyone got a function that can do this?


This isn't really a regular expression question, since you'd use an
expression to check if a string matched your requirements but not to
generate such a string.

A function should be easy: just loop 8 times over spitting out a random
char between a and z or 0 and 9 (use rand() to generate a number between
0 and 35 and then map that to the char).


% % Thanks for your help


Enjoy :-)


HTH & HAND


:-D

-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to