Return to Snippet

Revision: 6412
at January 15, 2010 12:26 by mattkenefick


Updated Code
function createRandomKey($amount){
	$keyset  = "abcdefghijklmABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
	$randkey = "";
	for ($i=0; $i<$amount; $i++)
		$randkey .= substr($keyset, rand(0, strlen($keyset)-1), 1);
	return $randkey;	
}

Revision: 6411
at May 20, 2008 13:05 by mattkenefick


Initial Code
function createKey($amount){
	$keyset = "abcdefghijklmABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
	$randkey = "";
	for ($i=0; $i<$amount; $i++)
		$randkey .= substr($keyset, rand(0,count($keyset)-1), 1);
	return $randkey;	
}

Initial URL


Initial Description
Creates a variable length key from a pre-defined set of characters.

Initial Title
PHP: Random Key Generator

Initial Tags


Initial Language
PHP