PHP从规定字符中生成固定位数随即串

 1 /**
 2  * 从规定字符中生成固定位数随即串
 3  * @param int $l 位数
 4  * @param string $c 数据来源字符串
 5  * @return string 返回随即串
 6  */
 7 public static function mt_rand_str ($l$c = 'abcdefghijklmnopqrstuvwxyz1234567890')
 8 {
 9     $lenC = strlen($c);
10     for ($s = '', $cl = $lenC-1, $i = 0; $i < $l$s .= $c[mt_rand(0, $cl)], ++$i);
11     return $s;
12 }
原文地址:https://www.cnblogs.com/diguaer/p/5589978.html