随机串

function random($length, $chars = '0123456789') {
$hash = '';
$max = strlen($chars) - 1;
for($i = 0; $i < $length; $i++) {
$hash .= $chars[mt_rand(0, $max)];
}
return $hash;
}

var_dump(random(6, '123456789abcdefghijklmnpqrstuvwxyzABCDEFGHIJKLMNPQRSTUVWXYZ'));
posted @   pengcx  阅读(112)  评论(0编辑  收藏  举报
努力加载评论中...
点击右上角即可分享
微信分享提示