时间:2021-07-01 10:21:17 帮助过:3人阅读
/**
* 生成随机数
* @param int $length ?度
* @return string
*/
function randomkey($length) {
$hash = '';
$chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890';
$max = strlen($chars) - 1;
for ($i = 0; $i < $length; $i++) {
$hash .= $chars[mt_rand(0, $max)];
}
return $hash;
}