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 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'; Link to comment https://forums.phpfreaks.com/topic/243382-randomize-by-percentage/#findComment-1249933 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.