A php code to generate a 16-bit random number (two methods), 16-bit random number _ PHP Tutorial

Source: Internet
Author: User
A php code that generates a 16-bit random number (two methods), a 16-bit random number. One php code to generate a 16-bit random number (two methods), one php code to generate a 16-bit random number, and two php methods to generate a random number. Method 1? Php $ amt_rand (100000 a php code that generates a 16-bit random number (two methods), a 16-bit random number

A php code that generates a 16-bit random number. php can generate a random number in two ways.

Method 1
$ A = mt_rand (0000000,99999999 );
$ B = mt_rand (0000000,99999999 );
Echo $ a. $ B;

Method 2:
$ A = range (0, 9 );
For ($ I = 0; $ I <16; $ I ++ ){
$ B [] = array_rand ($ );
} // Www.yuju100.com
Var_dump (join ("", $ B ));
// Result: string (16) "0179571910024734"

Reference link:

  • Several examples of generating non-repeated random numbers using php
  • How does php generate a 6-digit random number? example of a php random number
  • Three methods for generating random numbers using php
  • Example of a php random number. The php background color is displayed randomly.
  • Php random number generation function example
  • Sample code for php random number generation
  • Php generates random numbers. php generates fixed-digit random numbers.
  • Example of generating a random number or string using php

How does php generate a 16-bit random number? Only numbers

A little opportunistic

A php code that generates four random numbers

A random number of four digits.
Rand)
A four-character random string that combines numbers and characters:

Function GetRandStr ($ len)
{
$ Chars = 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", "0", "1 ", "2 ",
"3", "4", "5", "6", "7", "8", "9"
);
$ CharsLen = count ($ chars)-1;
Shuffle ($ chars );
$ Output = "";
For ($ I = 0; $ I <$ len; $ I ++)
{
$ Output. = $ chars [mt_rand (0, $ charsLen)];
}
Return $ output;
}
Echo GetRandStr (4 );

Callback (two methods): a 16-bit random number code generated by php to generate a 16-bit random number. php can generate a random number in two ways. Method 1? Php $ a = mt_rand (100000...

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.