开发者

Generting random (alphanumeric) string in PHP [duplicate]

This question already has answers here: Clo开发者_运维知识库sed 12 years ago.

Possible Duplicate:

Generating (pseudo)random alpha-numeric strings

How to genearte random string in PHP? Numbers are not a problem, but how to deal with letters efficiently?


You might be best of using the normal random function in combination with chr From the php manual comments: http://php.net/manual/en/function.chr.php

<?php
for($i=0; $i<7; $i++){
    $random_string .= chr(rand(0,25)+65);
}
echo $random_string;
?>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜