Php obtains a specified number of random strings. php obtains the number of strings.

Source: Internet
Author: User

Php obtains a specified number of random strings. php obtains the number of strings.

This example describes how php can obtain a specified number of random strings. We will share this with you for your reference. The details are as follows:

Function getARandLetter ($ number = 1) {if ($ number = 0) return FALSE; // remove 0 $ number = $ number <0? -$ Number: $ number; // if the value is less than zero, take the positive value $ letterArr = array ('A', 'B', 'C', 'D', 'E ', 'F', 'G', 'h', 'I', 'J', 'k', 'l', 'M', 'n', 'O ', 'P', 'Q', 'R','s ', 't', 'U', 'V', 'w', 'x', 'y ', 'Z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'h', 'I ', 'J', 'k', 'l', 'M', 'n', 'O', 'P', 'Q', 'R','s ', 'T', 'U', 'V', 'w', 'x', 'y', 'z'); $ returnStr = ''; for ($ I = 0; $ I <$ number; $ I ++) {$ returnStr. = $ letterArr [rand (0, 51)];} return $ returnStr;} echo getARandLetter (8 );

Running result: lUJfScvS

PS: here we will provide you with an online tool with similar functions for your reference:

High-strength Password generator:
Http://tools.jb51.net/password/CreateStrongPassword

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.