IT Community - Software Programming, Web Development and Technical Support

How do I generate a random number from php?

This is a discussion on How do I generate a random number from php? within the PHP Programming forums, part of the Web Development category; How do I generate a random number from php? Can anyone tell me...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Web Development > PHP Programming

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 07-23-2007, 11:08 PM
kingmaker kingmaker is offline
D-Web Genius
 
Join Date: Jun 2007
Posts: 882
kingmaker is on a distinguished road
Send a message via Yahoo to kingmaker
Question How do I generate a random number from php?

How do I generate a random number from php?

Can anyone tell me
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 07-24-2007, 12:38 AM
vijayanand vijayanand is offline
D-Web Analyst
 
Join Date: Feb 2007
Posts: 293
vijayanand is on a distinguished road
Default Re: How do I generate a random number from php?

rand ( [int min, int max] )

this function will produce u to print the random numbers from the minimum number to the maximum number

for example

echo rand ( 0, 1000);
this will print the random number from 0 to 1000.
__________________

J.Vijayanand
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 07-24-2007, 01:56 AM
oxygen oxygen is offline
D-Web Architect
 
Join Date: Jun 2007
Posts: 633
oxygen is on a distinguished road
Default Re: How do I generate a random number from php?

To generate a random number between 0 and 100 do this:


srand((double)microtime()*1000000);
echo rand(0,100);


Read more in the php manual:
PHP: rand - Manual
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to create random number in c? Murali C and C++ Programming 6 07-22-2008 11:26 PM
To get random number in mysql Murali Database Support 7 11-05-2007 10:34 PM
How do I generate a random number from php? itbarota PHP Programming 2 09-25-2007 07:57 AM
How to generate random password generator.using javascript.? itbarota HTML, CSS and Javascript Coding Techniques 1 07-25-2007 11:42 PM
How to Generate Various types of random numbers using SQLServer ? Archer Database Support 1 07-16-2007 01:26 AM


All times are GMT -7. The time now is 11:56 AM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0