【问题标题】:Generting random (alphanumeric) string in PHP [duplicate]在PHP中生成随机(字母数字)字符串[重复]
【发布时间】:2011-06-18 02:10:35
【问题描述】:

可能重复:
Generating (pseudo)random alpha-numeric strings

如何在 PHP 中生成随机字符串?数字不是问题,但是如何高效地处理字母呢?

【问题讨论】:

    标签: php


    【解决方案1】:

    您可能最好将普通随机函数与chr 结合使用 来自php手册cmets: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;
    ?>
    

    【讨论】:

      猜你喜欢
      • 2013-08-06
      • 2010-09-08
      • 1970-01-01
      • 1970-01-01
      • 2015-08-16
      • 1970-01-01
      • 2013-07-26
      • 1970-01-01
      • 2021-04-05
      相关资源
      最近更新 更多