Created
July 29, 2011 15:01
-
-
Save fredkelly/1113988 to your computer and use it in GitHub Desktop.
Determine win (boolean) based on given odds string.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function determine_win($odds) { | |
$range = explode('/', $odds); | |
return in_array(mt_rand(0, $range[1]), range(0, $range[0])); | |
} | |
$one_in_ten = determine_win('1/10'); | |
$fifty_fifty = determine_win('1/2'); | |
$three_in_seven = determine_win('3/7'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment