Jump to content

[SOLVED] Create random alphanumeric code...


iPixel

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/115233-solved-create-random-alphanumeric-code/
Share on other sites

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.