PHP随机生成随机个数的字母组合示例_php技巧

WBOY
Release: 2016-05-17 08:51:11
Original
1100 people have browsed it

在很多系统环境下大家都会用到字母组合各种编码,下面推荐大家非常实用的PHP代码。

$num由几个字母组合。

$s字母包含大小写,可以自己调配大写还小写。

复制代码 代码如下:

function makecode($num=4) {
$re = ”;
$s = ‘abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
while(strlen($re)$re .= $s[rand(0, strlen($s)-1)]; //从$s中随机产生一个字符
}
return $re;
}
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!