Home > Backend Development > PHP Tutorial > How to generate a random string in php using a specified character list, php characters_PHP tutorial

How to generate a random string in php using a specified character list, php characters_PHP tutorial

WBOY
Release: 2016-07-13 09:56:50
Original
813 people have browsed it

php uses a specified character list to generate a random string, php characters

The example in this article describes how php uses a specified character list to generate a random string. Share it with everyone for your reference. The details are as follows:

<&#63;php
function randomString($len) {
  srand(date("s"));
  $possible="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890!@#$%^&*()";
  $str="";
  while(strlen($str)<$len) {
   $str.=substr($possible,(rand()%(strlen($possible))),1);
  }
  return($str);
}
&#63;>
Copy after login

I hope this article will be helpful to everyone’s PHP programming design.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/986076.htmlTechArticlephp method to generate a random string using a specified character list, php characters This article describes the example of php using a specified character list to generate Random string method. Share it with everyone for your reference. ...
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