Skip to content

Instantly share code, notes, and snippets.

@fredkelly
Created July 29, 2011 15:01
Show Gist options
  • Save fredkelly/1113988 to your computer and use it in GitHub Desktop.
Save fredkelly/1113988 to your computer and use it in GitHub Desktop.
Determine win (boolean) based on given odds string.
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