Php generates a random string with a specified number of digits (length)

Source: Internet
Author: User
Php generates a random string with a specified number of digits (length)

  1. /**
  2. * Generate a string of the specified length
  3. * By bbs.it-home.org
  4. */
  5. Function create_random_string ($ random_length ){
  6. $ Chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 ";
  7. $ Random_string = '';
  8. For ($ I = 0; $ I <$ random_length; $ I ++ ){
  9. $ Random_string. = $ chars [mt_rand (0, strlen ($ chars)-1)];
  10. }
  11. Return $ random_string;
  12. }

The random string value range is random {0-9, A-Z, a-z.

>>> Articles you may be interested in: PHP random string generation function php random string generation function PHP two examples of generating random string PHP two methods of generating random string a simple php random generation string function very useful three PHP random string function generator php generate random number example php create readable random string code use php generate a random string code php generate random numbers and letters instance code

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.