/**
* 生成随机码
* @param int $len 随机字符串长度 默认值4
* @param int $len 随机字符串长度
*
*/
function randStr($len = 4, $type = 'num')
{
$typelist =[
'num' => '123456789',
'str' => 'abcdefghijklmnopqrstuvwxyz',
'both' => 'abcdefghijklmnopqrstuvwxyz123456789',
];
return substr(str_shuffle($typelist[$type]),0,$len);
}
//随机字符串
function nonce_str($leng=32)
{
$str = 'QWERTYUIOPASDFGHJKLZXVBNMqwertyuioplkjhgfdsamnbvcxz';
return substr(str_shuffle($str),0,$leng);
}
08-14
2563
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
06-15
530
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
10-21
1603
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)