Generating a 4 digit random number in PHP

Hello guys,

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

      randcode = Int(9000 * Rnd + 1000)

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

Who is Participating?
aldanchConnect With a Mentor Commented:
This may work for you.

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

Open in new window

pvg1975Author Commented:
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.