Im looking to for a way to make something show up on a %, i need this to work with (if).
example, when the page is loaded text will say Good Day 95% of the time, and 4% says Hello, and 1% says You Win.
Sorry if I'm not making any sense, I'm finding this hard to put in to words.
Looking for a way to make odds
Moderator: General Moderators
Re: Looking for a way to make odds
Code: Select all
$intHit = rand(1,100);
if ($intHit <= 95) {
$strMsg = 'Good Day';
}
elseif ($intHit <= 99) { // 95 + 4, Anything 95 and under would have hit above
$strMsg = 'Hello';
}
else { // The only thing that would hit here is 100, which is 1% chance
$strMsg = 'You Win';
}
Re: Looking for a way to make odds
thank you very much. this should help me a lot