Random episodes of unique numbers

Source: Internet
Author: User
Randomly generate unique numbers
Randomly produces a unique 6-digit number and corresponding 12-digit number. For example: 10,000 required
Such as:
244855 587753043808
558676 168139952943

------Solution--------------------
The random out of the data recorded, the next random time than the right, temporarily only think of such a method, but very troublesome, know there are other ways not ....
------Solution--------------------
for ($i =10000; $i <=99999; $i + +) {
Echo "244855 5877530{$i}
";
}
------Solution--------------------
You can build this
PHP Code
for ($i =0; $i <30000; $i + +) {//Generate 30,000 6-digit $r [] = rand (100000, 999999);} if (Count (Array_flip (Array_count_values ($r))) >1) {//Check for duplicate exit (' Duplicate, re-execute ');} foreach (Array_chunk ($r, 3) as $t) {//Cut into 3 groups of $res [] = array ($t [0], $t [1]. $t [2]);//Put in an array, you save}print_r ($res) according to your needs;
------Solution--------------------
discuss

PHP Code

$check = Array ();
for ($i =0; $i <30000; $i + +)
{
Do
{
$rnum = rand (100000, 999999);
}
while (Isset ($check [$rnum]);
$check [$rnum] = 1;
}
Print_r (Array_keys ($check));


This is a build of 10,000 not ...

------Solution--------------------
PHP code
!--? phps = range (100000,999999); Srand ((    float) microtime () *1000000); Shuffle (s); $i = 10000;foreach (s as) {if ($i--0) break; echo "\ r \ n";}? --> 
  • 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.