1
I have this function that works as I want. It takes a value between -2 and 2 to set the priority to choose between two strings.
My point is: How can I simplify the function?
function random_str($val){
if($var == '-2') { $out = array('str1','str2','str2','str2'); }else
if($var == '-1') { $out = array('str1','str2','str2'); }else
if($var == '0') { $out = array('str1','str2',); }else
if($var == '1') { $out = array('str1','str1','str2'); }else
if($var == '2') { $out = array('str1','str1','str1','str2'); }
return $out[array_rand($out)];
}
Good, I like this solution! ;)
– helderk