Return to Snippet

Revision: 45428
at April 30, 2011 01:04 by tasmanweb


Initial Code
/*
returns a random alphanumeric text of length $codelength (defaults to 4 characters)
usage echo random_text(); or $output = random_text();
48 to 57 are the numbers
65 to 90 are UpperCase
97 to 122 are LowerCase
*/
function random_text($code_length = 4){
	for($code_length, $newcode = ''; strlen($newcode) < $code_length; $newcode .= chr(!rand(0, 2) ? rand(48, 57) : (!rand(0, 1) ? rand(65, 90) : rand(97, 122))));
	return $newcode;
}

Initial URL


Initial Description


Initial Title
random alphanumeric text of length $codelength

Initial Tags
php, function

Initial Language
PHP