Results 1 to 4 of 4

Thread: random number generator in php?

Hybrid View

  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
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

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

  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

Recent Articles