A PHP code that generates 16-bit random numbers (two methods)

Source: Internet
Author: User

PHP generates 16-bit random numbers of code, and PHP generates two methods of random numbers.

Method 1
<?php
$a = Mt_rand (10000000,99999999);
$b = Mt_rand (10000000,99999999);
echo $a. $b;

Method 2:
<?php
$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

A PHP code that generates 16-bit random numbers (two methods)

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.