How to generate 500,000 non-repeating 8-digit Arabic numerals with PHP, please?

Source: Internet
Author: User
Ask how to generate 500,000 non-repeating 8-digit Arabic numerals with PHP. How does the code write? Ask for help? Urgent. For complete code. Auto carriage return blank line: Thank you, seniors.


Reply to discussion (solution)

for ($i = 0; $i < 500000; $i + +)

for ($i = 10000000; $i < 10500000; $i + +)

for ($i = 10000000; $i < 10500000; $i + +)
You come here too?? You're not a regular water-mixing zone.

Do you work in PHP? Curious and own ....

Function Rand_num (& $num) {$n = rand (10000000,99999999), if (In_array ($n, $num)) {Rand_num (& $num);} return $n;} for ($i =0; $i <500000; $i + +) {$num [] = Rand_num (& $num);} Print_r ($num);

Reference 2 floor xming4321 reply: for ($i = 10000000; $i < 10500000; $i + +)
You come here too?? You're not a regular water-mixing zone.

Do you work in PHP? Curious and own .... I'm sending a yellow piece.

The 2 floor of the largest can only be 1049999, obviously does not meet the requirements.
4 floor is possible.

Is the 4 floor slow?

PHP code?1234567891011121314function rand_num (& $num) {$n = rand (10000000,99999999), if (In_array ($n, $num)) {Rand_ Num (& $num); } return $n;} for ($i =0; $i <500000;
Instantly the card is dead, but can solve the request, haha

Reference 4 Floor zhangbin1988 's reply: PHP code?1234567891011121314function rand_num (&amp; $num) {$n = rand (10000000,99999999); if ( In_array ($n, $num)) {rand_num (&amp; $num);
Do you want to cycle 50W can not slow it?

PHP code?1234567891011121314function rand_num (& $num) {$n = rand (10000000,99999999), if (In_array ($n, $num)) {Rand_ Num (& $num); } return $n;} for ($i =0; $i <500000;

Depressed. Questions about my PHP version? Call-time pass-by-reference has been removed!!!

Rand_num (& $num)
Change for
Rand_num ($num);

PHP 5.3, cannot explicitly pass a reference

Besides, your code is not properly written in its own right.

The 2 floor of the largest can only be 1049999, obviously does not meet the requirements.
4 floor is possible. You wrote one less.

  • 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.