A PHP generates 16-bit random number code (two methods), 16-bit random number
PHP generates 16-bit random numbers of code, and PHP generates two methods of random numbers.
Method 1
$a = Mt_rand (10000000,99999999);
$b = Mt_rand (10000000,99999999);
echo $a. $b;
Method 2:
$a = range (0,9);
for ($i =0; $i <16; $i + +) {
$b [] = Array_rand ($a);
}//Www.yuju100.com
Var_dump (Join ("", $b));
Result String (16) "0179571910024734"
Reference Links:
- PHP generates several examples of non-repeating random numbers
- PHP How to generate 6-bit random number, PHP random number example
- Three ways to generate random numbers in PHP
- PHP Random number example, PHP background color random display
- PHP Random number Generation Function Example
- PHP random number Generation sample code
- PHP generates random numbers, PHP generates a fixed number of random digits
- Examples of PHP generating random numbers or strings
How does PHP generate 16-bit random numbers? Only numbers
A bit of an opportunistic means
A PHP code that generates four-bit random numbers
Four-bit random number of pure digits
rand (1000,9999)
number and character mash-up four-bit random string:
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);
http://www.bkjia.com/PHPjc/879486.html www.bkjia.com true http://www.bkjia.com/PHPjc/879486.html techarticle a PHP generates 16-bit random number code (two methods), 16-bit random number a PHP generated 16-bit random number of code, PHP generates a random number of two ways. Method 1: Php $a = mt_rand (100000 ...