Revision: 691
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at July 31, 2006 08:07 by niyi_gbads
Initial Code
function str_rand ($minlength, $maxlength, $useupper=true, $usespecial=false, $usenumbers=true) { $key =""; $charset = "abcdefghijklmnopqrstuvwxyz"; if ($useupper) $charset .= "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; if ($usenumbers) $charset .= "0123456789"; if ($usespecial) $charset .= "~@#$%^*()_+-={}|]["; // Note: using all special characters this reads: "~!@#$%^&*()_+`-={}|\\]?[\":;'><,./"; if ($minlength > $maxlength) $length = mt_rand ($maxlength, $minlength); else $length = mt_rand ($minlength, $maxlength); for ($i=0; $i<$length; $i++) $key .= $charset[(mt_rand(0,(strlen($charset)-1)))]; return $key; }
Initial URL
Initial Description
This snippet generates a random string of random length
Initial Title
Random Number Generator
Initial Tags
Initial Language
PHP