php生成随机数 自定义函数 randstr($length)
2012-06-27 11:05
330 查看
function randstr($len=6){
$chars='abcdefghijklmnopqrstuvwxyz0123456789';
#characters to build the password from
mt_srand((double)microtime()*1000000*getmypid());
#seed the random number generater (must be done)
$password='';
while(strlen($password)<$len)
$password.=substr($chars,(mt_rand()%strlen($chars)),1);
return $password;
}
$salt = randstr();
$chars='abcdefghijklmnopqrstuvwxyz0123456789';
#characters to build the password from
mt_srand((double)microtime()*1000000*getmypid());
#seed the random number generater (must be done)
$password='';
while(strlen($password)<$len)
$password.=substr($chars,(mt_rand()%strlen($chars)),1);
return $password;
}
$salt = randstr();
相关文章推荐
- php生成随机数:自定义函数 randstr($length)
- 用PHP生成随机数的函数
- php简单生成随机数的方法
- php随机数怎么获取?一个简单的函数就能生成
- 一个php生成16位随机数的代码(两种方法)
- PHP的函数-----生成随机数、日期时间函数
- php生成随机数
- php生成不重复随机数、数组的4种方法分享
- PHP随机数生成与使用解析
- php生成N个不重复的随机数实例
- PHP生成不重复随机数的方法汇总
- PHP生成随机数的方法实例分析
- php下的GUID用法,生成随机数
- PHP随机数生成与使用解析
- php生成随机数
- php生成随机数的三种方法
- php生成2位小数的随机数,随机数字+字母
- php生成随机数
- php使用codebase生成随机数