iPixel Posted July 17, 2008 Share Posted July 17, 2008 Hey dudez and dudettes, im working on this little fun project where instead of people mailing back RSVP's from my invitations they will also have the option to RSVP via a website. So each invitation will have a code A1B2C3 which the user will input and the site will automatically know who that person is and the amount of people on that invitation. I really dont feel like randomly crating the 5 character codes myself and figured it would be more usefull for me to learn how to do it the php way hehe... So basically i want to run a script that will create lets say 100 five character alphanumeric codes all caps plz. That look like F9M3C1. Thank You all who help. Quote Link to comment https://forums.phpfreaks.com/topic/115233-solved-create-random-alphanumeric-code/ Share on other sites More sharing options...
anthrt Posted July 17, 2008 Share Posted July 17, 2008 echo strtoupper(substr(md5(rand().rand()), 0, 5)); Quote Link to comment https://forums.phpfreaks.com/topic/115233-solved-create-random-alphanumeric-code/#findComment-592454 Share on other sites More sharing options...
iPixel Posted July 17, 2008 Author Share Posted July 17, 2008 LoL i though it would be at least a little harder than that. Thank You Very much... this is perfec. Quote Link to comment https://forums.phpfreaks.com/topic/115233-solved-create-random-alphanumeric-code/#findComment-592456 Share on other sites More sharing options...
kenrbnsn Posted July 17, 2008 Share Posted July 17, 2008 That solution will only give you letters in the range of 'A' to 'F', the following solution uses the whole alphabet: <?php $a = array_merge(range(0,9),range('A','Z')); shuffle($a); echo implode('',array_slice($a,0,5)); ?> Ken Quote Link to comment https://forums.phpfreaks.com/topic/115233-solved-create-random-alphanumeric-code/#findComment-592575 Share on other sites More sharing options...
Barand Posted July 17, 2008 Share Posted July 17, 2008 So basically i want to run a script that will create lets say 100 five character alphanumeric codes all caps please. That look like F9M3C1. Erm, F9M3C1 is 6 characters Quote Link to comment https://forums.phpfreaks.com/topic/115233-solved-create-random-alphanumeric-code/#findComment-592687 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.