pouncer Posted May 14, 2007 Share Posted May 14, 2007 Hey guys, I want to generate a 32 length string which contains both number 0-9 and letter A-Z letters must be caps, any ideas guys? Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted May 14, 2007 Share Posted May 14, 2007 Here's one method: <?php $str = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'; $randstr = ''; while (strlen($randstr) < 32) $randstr .= $str{rand(0,strlen($str))}; echo '[' . strlen($randstr) . '] ' . $randstr; ?> Ken Quote Link to comment Share on other sites More sharing options...
chigley Posted May 14, 2007 Share Posted May 14, 2007 Another: <?php $random = rand(-1000000, 1000000); $md5 = md5($random); $string = strtoupper($md5); echo $string; ?> Quote Link to comment Share on other sites More sharing options...
pouncer Posted May 14, 2007 Author Share Posted May 14, 2007 perfect, thanks guys Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.