用php生成许多随机字母

时间:2015-07-20 20:10:45

标签: php

我想制作很多随机词我已经有了创建一个

的代码
function generateRandomString($length = 10) {
    $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
    $charactersLength = strlen($characters);
    $randomString = '';
    for ($i = 0; $i < $length; $i++) {
        $randomString .= $characters[rand(0, $charactersLength - 1)];
    }
    return $randomString;
}
echo generateRandomString();

任何人都可以告诉我如何在不点击一整天刷新的情况下让他们更多?

1 个答案:

答案 0 :(得分:1)

这对我有用:

function generateRandomString($length = 10) {
    $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
    $charactersLength = strlen($characters);
    $randomString = '';
    for ($i = 0; $i < $length; $i++) {
        $randomString .= $characters[rand(0, $charactersLength - 1)];
    }
    return $randomString;
}

for ($i=0; $i < 10; $i++) {
    echo generateRandomString() . "<br>";
}