JaTochNietDan Posted March 2, 2009 Share Posted March 2, 2009 How would you, calculate a percentage? Like say I want there to be a 30% chance of this topic to be posted when I click post? I tried messing with rand(0,10) but I dont think that would account for percentages correctly. Is there a function? Thanks for any replies Quote Link to comment Share on other sites More sharing options...
rhodesa Posted March 2, 2009 Share Posted March 2, 2009 if(rand(1,100) <= 30){ echo "30% of the time"; } p.s. - if your percentages are divisible by 10, you can use 1-10 and 3 instead Quote Link to comment Share on other sites More sharing options...
JaTochNietDan Posted March 2, 2009 Author Share Posted March 2, 2009 if(rand(1,100) <= 30){ echo "30% of the time"; } p.s. - if your percentages are divisible by 10, you can use 1-10 and 3 instead hmm, this makes sense thanks 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.