Solved

PHP: script to generate 10 random numbers?

Posted on 2010-11-29
5
444 Views
Last Modified: 2012-05-10
Hello experts,

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

Any ideas?

thanks.
0
Comment
Question by:epifanio67
  • 3
  • 2
5 Comments
 
LVL 27

Accepted Solution

by:
yodercm earned 500 total points
ID: 34235100
$number=rand()%1000000000;
0
 
LVL 27

Expert Comment

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

Author Comment

by:epifanio67
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

by:epifanio67
ID: 34235318
I got it... thank you
0
 
LVL 27

Expert Comment

by:yodercm
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
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…

746 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now