How can I create a function of probability, choosing between two strings with a probability range between 1/3, 1/2, 1/1, 2/1, 3/1
My value comes from a slider in a range between -2 and 2
this is my code:
$out = array('str1','str2');
$out = $out[array_rand($out)];
I want something like this:
$val = 0; //-2=1/3, -1=1/2, 0=1/1, 1=2/1, 2=3/1
function random_str($val){
...
retunt $myRandomValue;
}
Aucun commentaire:
Enregistrer un commentaire