Home > Backend Development > PHP Tutorial > PHP function to generate custom length random string sharing_PHP tutorial

PHP function to generate custom length random string sharing_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-13 10:30:49
Original
941 people have browsed it

php randomly generates strings and you can define the length you need. This is often encountered in actual application development.

Copy code The code is as follows:

//Randomly generate string
function random($length) {
srand(date("s"));
$possible_charactors = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
$string = "";
while(strlen($string)<$length) {
$ string .= substr($possible_charactors,(rand()%(strlen($possible_charactors))),1);
                                                                                                                                                                                                                    ; >


http://www.bkjia.com/PHPjc/764619.htmlwww.bkjia.com

truehttp: //www.bkjia.com/PHPjc/764619.htmlTechArticlephp randomly generates strings and you can define the length you need. This is often encountered in actual application development. Copy the code The code is as follows: // Randomly generate string function random($...
Related labels:
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template