Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
Solved

PHP: script to generate 10 random numbers?

Posted on 2010-11-29
Medium Priority
456 Views
Hello experts,

I need to write a php script that randomly generates 10 digit numbers.

Any ideas?

thanks.
0
Question by:epifanio67
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points
• 3
• 2

LVL 27

Accepted Solution

Cornelia Yoder earned 2000 total points
ID: 34235100
\$number=rand()%1000000000;
0

LVL 27

Expert Comment

ID: 34235117
The % is the "remainder" operator.  You can adjust the number of digits you get by adjusting the 1000000000 number.
0

Author Comment

ID: 34235258
thank you expert,

\$number=rand()%1000000000;
it generates a random 5 digit number; but every time one refreshes the browser..

what I meant is: I need to create an array of random numbers
using rand(8,20)

see what I mean?

thanks,
regards
0

Author Closing Comment

ID: 34235318
I got it... thank you
0

LVL 27

Expert Comment

ID: 34235609
Glad you got what you needed ... it wasn't exactly clear from

"...script to generate 10 random numbers" and
"...script that randomly generates 10 digit numbers"

which it was that you actually needed, but creating an array of 10 numbers is pretty easy, so I figured you needed the other.

0

Featured Post

Question has a verified solution.

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

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses
Course of the Month11 days, 19 hours left to enroll