timmah1 Posted November 13, 2007 Share Posted November 13, 2007 I'm trying to set up a simple little referral code for people that register at our site. I want it to generate as soon as they register, so that it will display upon successul registration. I'm trying to make it a random string of letters and numbers, no more than 8 characters long, but to be honest, I have no idea where to start. The tutorials I did find wasn't really helping. So the questiton I have is, how do you generate a random string of letters and numbers no more than 8 characters long? Is this even possible? Thank you in advance Link to comment https://forums.phpfreaks.com/topic/77171-random-help/ Share on other sites More sharing options...
kenrbnsn Posted November 13, 2007 Share Posted November 13, 2007 There are many ways to do this, here is one way: <?php <?php $seed_array = array_merge(range('a','z'),range('A','Z'),range(0,9)); $rand_ary = array_rand($seed_array,; $rand_str = ''; foreach($rand_ary as $rk) $rand_str .= $seed_array[$rk]; echo $rand_str."\n"; ?> Ken Link to comment https://forums.phpfreaks.com/topic/77171-random-help/#findComment-390753 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.