supertrucker Posted April 21, 2008 Share Posted April 21, 2008 Is there a way to create a random five character string? I'm working on a "Forgot Password" page, and need to create a five character random password. Any help would be much appreciated, thanks!ST Link to comment Share on other sites More sharing options...
justsomeguy Posted April 21, 2008 Share Posted April 21, 2008 function generate_password ($len){ $user_pw = ''; while (strlen($user_pw) < $len) { $char = mt_rand(49, 122); if (($char > 57 && $char < 65) || ($char > 90 && $char < 97)) { continue; } $user_pw .= chr($char); } return $user_pw;} Link to comment Share on other sites More sharing options...
supertrucker Posted April 21, 2008 Author Share Posted April 21, 2008 Thank you very much, just what I was looking for! Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.