// function for random string, in this function there are 6 different types of string functions are available.
they are alphanumeric,numeric,nonzero numeric,alphabets,alpha numerics with special charectors like -_#@ and unique one.
function randomKey($type = 'alphanum', $len = 8)
{
switch($type)
{
case 'alphanum' :
case 'numeric' :
case 'nonzero' :
case 'alpha' :
case 'alphanumspechar':
switch ($type)
{
case 'alphanum' : $pool = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
break;
case 'numeric' : $pool = '0123456789';
break;
case 'nonzero' : $pool = '123456789';
break;
case 'alpha' : $pool = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
break;
case 'alphanumspechar': $pool = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-#@'; break;
}
$str = '';
for ($i=0; $i < $len; $i++)
{
$str .= substr($pool, mt_rand(0, strlen($pool) -1), 1);
}
return $str;
break;
case 'unique' : return md5(uniqid(mt_rand()));
break;
}
}
[Monday, May 12, 2008
|
0
comments
]
Popular Posts
- MySQL stored procedure&triggers
- php questions
- Php Questions
- How we canmove into last changed position on info window close event On google map
- Pattern Matching in mysql
- MySQL INDEX
- MYSQL joins
- Jquery based dynamic adding and removal of html elements.
- securing a form with captcha
- Comparing a date with current date
0 comments
Post a Comment
Please put your comments here. your questions, your suggestions, also what went wrong with me.