Page 1 of 1

Assigning Random Values

Posted: Mon Apr 09, 2007 1:03 pm
by royrogersrevenge
I'm a bit new and could use some help on something.

I'd like to randomly assign values to entries in a table. How would I do this while ensuring that all values in a certain range(1-16, in this instance) are used and not repeated?

Posted: Mon Apr 09, 2007 1:11 pm
by Kieran Huggins

Code: Select all

$numbers = range(1,16); // create an array of numbers
shuffle($numbers); // shuffle the deck
foreach($numbers as $num){
//... 
}