Home > Backend Development > PHP Tutorial > Generate string + numeric random number of any length_PHP tutorial

Generate string + numeric random number of any length_PHP tutorial

WBOY
Release: 2016-07-13 17:42:59
Original
733 people have browsed it

You can customize what string is generated and how long it is

[PHP] Code

Function random($length)

 {

 $hash = ;

$chars = ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz;

 $max = strlen($chars) - 1;

mt_srand((double)microtime() * 1000000);

 for($i = 0; $i < $length; $i++)

 {

 $hash .= $chars[mt_rand(0, $max)];

 }

return $hash;

 }

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/486024.htmlTechArticleYou can customize what string is generated and how long it is [PHP] code function random($length) { $hash = ; $chars = ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz; $max = st...
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