How PHP generates 10,000 non-repeating data,

Source: Internet
Author: User
Ask: How PHP generates 10,000 non-repeating data


Reply to discussion (solution)

10,000 what kind of data

1-10000 is not repeated.

Each time you want to generate 10,000 (or more), and it is a number. 17 bits per piece of data

Organize a 17-bit current time (accurate to seconds) value plus 1, and then from 1 to 10000, each time with the present time plus the value of the loop, there should be no heavy

$FN = ' random number. txt '; for ($i =0; $i <10000; $i + +) {  file_put_contents ($FN, sprintf ('%07d%08d ', rand (0, 9999999), rand (0, 99999999)). Php_eol, file_append);}

File random number in. txt is the result you want.

Time can be represented by time stamps.

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