How to generate random number in PHP?
February 18, 2006
Sometimes we need to have a random quote, news, testimonials being displayed on the front page of a website. We can use random number function to get a random id of a data to be generated.
The code is as below
——
$maxnum = 10;
srand(time());
$random_num = (rand()%$maxnum);
echo “The random number is: ” . $random_num;
Posted in
content rss
