EDIT:
For instance, if I had the numbers 1,3,5,7,9,11, .., I want to randomly pick from only those numbers, nothing in between
Moderator: General Moderators
Code: Select all
$options = '1,3,5,7,9,11,13,15,17,19';
$options = explode(',' , $options);
$rand_keys = array_rand($options , 5);
echo $options [$rand_keys[0]] . "\n";
echo $options [$rand_keys[1]] . "\n";
echo $options [$rand_keys[2]] . "\n";
echo $options [$rand_keys[3]] . "\n";
echo $options [$rand_keys[4]] . "\n";
Code: Select all
$chars = array(1, 3, 5, 11, 79);
shuffle($chars);
echo $chars[0]; //or $chars[1] or 2 or 3 or 4.. you get the idea ;p