?
Solved

Generating a 4 digit random number in PHP

Posted on 2009-04-20
2
Medium Priority
?
1,264 Views
Last Modified: 2012-05-06
Hello guys,

I am using the following code to generate a 4 digits random number in Active Server Pages:

      Randomize
      randcode = Int(9000 * Rnd + 1000)

Now, is it possible to do the same with PHP? Which would be the code for that?

Thanks.
0
Comment
Question by:pvg1975
2 Comments
 
LVL 8

Accepted Solution

by:
aldanch earned 2000 total points
ID: 24188164
This may work for you.


$random = (rand() % 9000) + 1000;

Open in new window

0
 

Author Closing Comment

by:pvg1975
ID: 31572436
Thanks!
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
The title says it all. Writing any type of PHP Application or API code that provides high throughput, while under a heavy load, seems to be an arcane art form (Black Magic). This article aims to provide some general guidelines for producing this typ…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses
Course of the Month15 days, 14 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question