php生成英文环境下具有阅读性的字符串

2011-01-15 阅读 40

php生成英文环境下具有阅读性的字符串。

感觉就和中国人的主谓宾一样去生成一个字符串,指定长度的,具有能够读出来的英文字符串。

默认长度6

<pre class="brush:php;">    function readable_random_string($length = 6){
    $conso=array("b","c","d","f","g","h","j","k","l",
    "m","n","p","r","s","t","v","w","x","y","z");
    $vocal=array("a","e","i","o","u");
    $password="";
    srand ((double)microtime()*1000000);
    $max = $length/2;
    for($i=1; $i<=$max; $i++)
    {
    $password.=$conso[rand(0,19)];
    $password.=$vocal[rand(0,4)];
    }
    return $password;
}

echo readable_random_string();
```

php 英文 可阅读 字符串

更新于 2023年03月28日