Generate Random Number
Posted on 2004-09-24
I'm using a news script called 'Cutenews' and within this script I can setup different news sections and each of these gets a number 1,2,3,4 etc. To display a news section on my web page I just drop in a piece of php with the appropriate news section number. This works great but I want to change it slightly. I want the news sections to appear randomly
i.e. instead of a variable
$section = 3
$section = a_random_number
I know how to generate a random number between 1-10, 1-20 etc but what I want to know is how to generate a random number from a list of given numbers e.g. if I have the numbers 1,3,4,6,8,9,10,12,15,18, how can I select one of these randomly?
Hope this is clear and many thanks in advance