gibigbig Posted July 31, 2011 Share Posted July 31, 2011 I am making an online game and when making a character, I want the gender chosen to be random, but controlled by a percentage. Example: $male = 80; // in % $female = 20; //in % Is there a function that will output "male" or "female" depending on the percentage of odds. Or do I have to make my own Quote Link to comment https://forums.phpfreaks.com/topic/243382-randomize-by-percentage/ Share on other sites More sharing options...
gizmola Posted July 31, 2011 Share Posted July 31, 2011 $gender = (rand(1, 10) > 2) ? 'M' : 'F'; Quote Link to comment https://forums.phpfreaks.com/topic/243382-randomize-by-percentage/#findComment-1249933 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.