Link to home
Start Free TrialLog in
Avatar of breeze351
breeze351

asked on

Need to get a random variable between 1 and 10 for a menu display.

I would like to display different images on the index page.  I was thinking the easiest way to do this would be to clock the time and just get the seconds.  This give me a variable between 1 and 10.  Load the image from an array with those images and display it.
Two questions:
1.  Does this make sense?
2.  How do I get just the seconds from the time?
ASKER CERTIFIED SOLUTION
Avatar of Norie
Norie

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of breeze351
breeze351

ASKER

Thanks that'll work.
rand() is a good solution for random numbers.  For the seconds portion of the time, use date('s') -- this will vary between 00 and 59.  To get a value between 1 and 10, based on seconds, you might use this.
<?php echo floor(date('s') / 6) + 1;

Open in new window