Random key generator

Generates a random key, a-Z 0-9 with no max length


Use as demonstrated in the comment. This can be good to append to a url and store in a database, and check for in a site registration during email validation (i.e. http://site.com/register.php?connfirmationcode=2QwYbI0mf4exPi



Posted on 31.07.2012 16:50 by guest

Tahnks !!

Posted on 10.12.2011 07:17 by guest

hi, guest your code is awesome than the original one.its user friendly and we can change our key characters easily by editing $options. i prefer your code than the original one posted.

Posted on 26.10.2011 01:25 by guest

Nice function guys. I will be using it to write a function for generating card pins for web login. Pins generated are stored on a database. When a pin is generated it is matched with the ones on the database if it exits, it is discarded if not exit, it is added to the database.

What do you think?

Posted on 28.03.2011 10:23 by guest

What about uniqueness?

Posted on 19.10.2010 18:28 by guest


Posted on 09.08.2010 10:57 by guest

nice, i use something similar
function generatekey($length)
$options = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
$code = "";
for($i = 0; $i < $length; $i++)
$key = rand(0, strlen($options) - 1);
$code .= $options[$key];

return $code;
// echo generatekey(10); // Ko9B69utve, returned result is random. not only is this good for ac validatin but has several other applicvations, eg captch ect its uses are limitless.