Results 1 to 4 of 4

Thread: random number generator in php?

  1. #1
    Join Date
    May 2013

    random number generator in php?

    Hello Guys,
    Please help me how can i generate random number in php? please share any related script or suggest me.
    Thanks for reply.

  2. #2
    Join Date
    Mar 2012
    Not a random number, but at least a DIFFERENT number can be generated by the time() function. This returns the number of seconds since Jan 1st 1970 00:00:00 hrs.

    This counter changes every second, and you could make it appear more random. How complicated the algorithm needs to be depends upon how many unique outputs are required. E.g. If the outputs are "yes", "no" and "maybe", which just need to appear random, then the last digit can be used to point to an offset (modulo 9) from the present position in a string of 9 characters "y", "n" and "m" e.g. $sequence="nymynmmny".

  3. #3
    Join Date
    Aug 2004
    "Well done....Consciousness to sarcasm in five seconds!" ~ Terry Pratchett, Night Watch

    How to Ask Questions the Smart Way (not affiliated with this site, but well worth reading)

    My Blog
    cwrBlog: simple, no-database PHP blogging framework

  4. #4
    Join Date
    May 2013
    Surendranagar Gujarat India
    print rand() . "<br>";
    //generates and prints a random number
    print rand(10, 30);
    //generates and prints a random number between 10 and 30 (10 and 30 ARE included)
    print rand(1, 1000000);
    //generates and prints a random number between on and one million

    Kishor Makwana
    Software Engineer
    Insight Softech

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center