php随机生成字符串可以自己定义自己所需要的长度,在实际应用开发中,经常遇到。
复制代码 代码如下:
//随机生成字符串
function random($length) {
srand(date("s"));
$possible_charactors = "0123456789abcdefghijklmnopqrstuvwxyz";
$string = "";
while(strlen($string)<$length) {
$string .= substr($possible_charactors,(rand()%(strlen($possible_charactors))),1);
}
return($string);
}
【说明】:本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:)!