码迷,mamicode.com
首页 > 其他好文 > 详细

获取随机的字符串

时间:2017-12-27 18:06:34      阅读:140      评论:0      收藏:0      [点我收藏+]

标签:col   rand   res   strlen   har   def   for   nop   style   

// 获取随机的字符串
function get_rand_char($length = 6) {
    $str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz";
    $strLength = 61;
    
    for($i = 0; $i < $length; $i ++) {
        $res .= $str [rand ( 0, $strLength )];
    }
    
    return $res;
}

 

获取随机的字符串

标签:col   rand   res   strlen   har   def   for   nop   style   

原文地址:https://www.cnblogs.com/zjj1990/p/8126111.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!