supanoob Posted January 4, 2007 Share Posted January 4, 2007 Ok, so i have a skill level and i want to turn that into a percentage which is easy enough to do but then i want to use that percentage to give them a chance to do something. for example:someone has a skill level of 35.i then want to take that and make it 35% which i can do.then i want to make it so they then have 35% chance to successfully do something.any advise me on how to do this. Link to comment https://forums.phpfreaks.com/topic/32843-solved-percentages/ Share on other sites More sharing options...
trq Posted January 4, 2007 Share Posted January 4, 2007 One way would be too use rand().[code]<?php$skill = 35;$randnumber = rand(1,100);if ($randnumber <= $skill) { // success} else { // failure}?>[/code] Link to comment https://forums.phpfreaks.com/topic/32843-solved-percentages/#findComment-152883 Share on other sites More sharing options...
supanoob Posted January 4, 2007 Author Share Posted January 4, 2007 that would work pretty well tbh :D thanks Link to comment https://forums.phpfreaks.com/topic/32843-solved-percentages/#findComment-152916 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.