brown2005 Posted June 4, 2009 Share Posted June 4, 2009 I have 20 players player1, player2, etc, etc. and 20 teams team1, team2, etc, etc. I would like to randomly assign the teams to the players. how can I do this please? Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted June 4, 2009 Share Posted June 4, 2009 You can use rand in a while loop to generate a random number to represent the team a player would go into. Quote Link to comment Share on other sites More sharing options...
Mark Baker Posted June 4, 2009 Share Posted June 4, 2009 or shuffle() an array of the teams, then allocate $team[0] to $player[0], $team[1] to $player[1], etc Quote Link to comment Share on other sites More sharing options...
brown2005 Posted June 4, 2009 Author Share Posted June 4, 2009 hi, thanks for the replies, would you be able to show me the code for this please as I am very new to arrays and have not really used them. thanks Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted June 4, 2009 Share Posted June 4, 2009 Well give it a try and if something broke, post your code here and we can help; but if you want to request this to be written, there is the Freelance forum. Quote Link to comment Share on other sites More sharing options...
Psycho Posted June 4, 2009 Share Posted June 4, 2009 How do you have your teams and players stored/assigned now? Are they in a database, hard coded, or what? Show us how you create/utilize tehm now and more specific help can be given. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.