Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
30 lines (29 loc) · 840 Bytes

File metadata and controls

30 lines (29 loc) · 840 Bytes
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?php
/*
* 常用函数文件
*
* @author:liangxifeng<liangxifeng833@163.com>
* @date : 2014-11-19
*/
/*
* 生成指定长度的随机字符串(包含大写英文字母, 小写英文字母, 数字)
* @demo :生成4位随机数的demo,randomStr(4); 结果:12RT
*
* @author: web
* @date : 2014-11-19
* @param : [int] - $length - 需要生成的字符串的长度
* @return: [string] - 指定长度包含大小写英文字母 和 数字 的随机字符串
*/
function randomStr($length)
{
//生成一个包含 大写英文字母, 小写英文字母, 数字 的数组
$arr = array_merge(range(0, 9), range('a', 'z'), range('A', 'Z'));
$str = '';
$arr_len = count($arr);
for ($i = 0; $i < $length; $i++)
{
$rand = mt_rand(0, $arr_len-1);
$str.=$arr[$rand];
}
return $str;
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.