欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

php创建可阅读随机字符串的代码

程序员文章站 2022-05-27 11:06:01
...
  1. /**************
  2. *@length - length of random string (must be a multiple of 2)
  3. **************/
  4. function readable_random_string($length = 6){
  5. $conso=array("b","c","d","f","g","h","j","k","l",
  6. "m","n","p","r","s","t","v","w","x","y","z");
  7. $vocal=array("a","e","i","o","u");
  8. $password="";
  9. srand ((double)microtime()*1000000);
  10. $max = $length/2;
  11. for($i=1; $i{
  12. $password.=$conso[rand(0,19)];
  13. $password.=$vocal[rand(0,4)];
  14. }
  15. return $password;
  16. }
  17. ?>
复制代码