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?
Assigning Random Values
Moderator: General Moderators
-
royrogersrevenge
- Forum Newbie
- Posts: 14
- Joined: Fri Apr 06, 2007 9:57 pm
- Kieran Huggins
- DevNet Master
- Posts: 3635
- Joined: Wed Dec 06, 2006 4:14 pm
- Location: Toronto, Canada
- Contact:
Code: Select all
$numbers = range(1,16); // create an array of numbers
shuffle($numbers); // shuffle the deck
foreach($numbers as $num){
//...
}