PHP generates a string of random numbers, letters, or numbers mixed with letters

Source: Internet
Author: User
This time for you to bring PHP to generate random numbers, letters or alphanumeric mixed strings, PHP to generate random numbers, letters or alphanumeric mixed string of considerations, the following is the actual case, together to see.

PHP generates random strings that can be specified as pure or plain letters or mixed.

example, you can specify a random string of length.

<?php//generates a random string function Rand_zifu ($what, $number) {$string = '; for ($i = 1; $i <= $number; $i + +) {//mixed $panduan =1; what = = 3) {if (==1) {$what = 1;} else{$what =2;} $panduan = 2; }//number if ($what ==1) {$string. =rand (0,9);} ElseIf ($what ==2) {//Letters $rand =rand (0,24); $b = ' a '; for ($a =0; $a <= $rand; $a + +) {$b + +;} $string. = $b;} if ($panduan ==2) $WH at=3; } return $string; } Echo Rand_zifu (3,10);

Believe that you have read the case of this article you have mastered the method, more exciting please pay attention to the PHP Chinese network other related articles!

Recommended reading:

PHP cropping without affecting the shape of the image

PHP picture clipping and thumbnail use examples to explain

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.