Web Hosting Talk







View Full Version : Beginner PHP question


Shodaime
05-23-2006, 01:56 PM
Hello, I'm working on a php script and need something that will give me a number that is between a set of numbers. Such as, for numbers between 1-10 they will have a certain value or if they're between 11-20 they will have a different value. I know this can be achieved with the symbols (>= and <=) but are there any other functions I can use to achieve this goal?

Jatinder
05-23-2006, 02:36 PM
You can use the rand(min,max) function.

rand(1,10) will give you a random integer beween 1 and 10

rand(11,20) will give you a random integer beween 11 and 20

Shodaime
05-23-2006, 02:57 PM
Works, thanks!

webviz
05-23-2006, 04:30 PM
You can use the rand(min,max) function.

rand(1,10) will give you a random integer beween 1 and 10

rand(11,20) will give you a random integer beween 11 and 20
That's pretty much it.