How to record a random number

Source: Internet
Author: User
I think I generate a lot of random numbers. Save all the random numbers. How do you do that?


Reply to discussion (solution)

It's not easy to write a library directly, or to write a document and save it.

It depends on how you generate these random numbers, one-time generation? Or do you generate 1 at a time every once in a while?
There are many ways to save it, the key is to see you these random numbers are what to use, run out on the throw or stay long-term use?
If you throw it out, you can put them in the global array $_session
After the session_destory is done.
For long-term use, you can save them in MySQL or a text document

Dizzy death, this change not simple, directly write the library, or directly write the document to save not write storage. I want to generate some random folder names. The array is then deposited. These are then randomly called in the HTML file. Downstairs is the positive solution.

It depends on how you generate these random numbers, one-time generation? Or do you generate 1 at a time every once in a while?
There are many ways to save it, the key is to see you these random numbers are what to use, run out on the throw or stay long-term use?
If you throw it out, you can put them in the global array $_session
After the session_destory is done.
For long-term use, you can save them in MySQL or text documents thanks for the positive solution


It depends on how you generate these random numbers, one-time generation? Or do you generate 1 at a time every once in a while?
There are many ways to save it, the key is to see you these random numbers are what to use, run out on the throw or stay long-term use?
If you throw it out, you can put them in the global array $_session
After the session_destory is done.
For long-term use, you can save them in MySQL or text documents thanks for the positive solution
I'd be happy if you'd be able to put a knot.


Dizzy death, this change not simple, directly write the library, or directly write the document to save not write storage. I want to generate some random folder names. The array is then deposited. These are then randomly called in the HTML file. Downstairs is the positive solution.

They have so clear ideas, why not do their own thinking to write code to achieve it?

Oh, he doesn't know what he needs.



Dizzy death, this change not simple, directly write the library, or directly write the document to save not write storage. I want to generate some random folder names. The array is then deposited. These are then randomly called in the HTML file. Downstairs is the positive solution.

They have so clear ideas, why not do their own thinking to write code to achieve it?

1. Cache Service Storage with Memcache
2. Use session storage, notice the life cycle, usually in 15-30 minutes
3. Use cookies to store the same attention to the life cycle

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