Hi folks,
my goal is to get 2 random elements from an array that are not identical. I'm having some trouble so could someone please have a look at my code? at present it returns the same 2 values everytime?
$file_array=array(1,2,3,4,5,6,7,8,9,10); /just for this forum, i'm actually getting images from an dir /
$maxval=count($file_array);
srand(microtime()*1000000);
while($returned_file_array[0]==$returned_file_array[1]) { //making sure not same
$key=rand(0, $maxval);
$returned_file_array[0]=$file_array[$key];
$key=rand(0, $maxval);
$returned_file_array[1]=$file_array[$key];
}
foreach($returned_file_array as $key => $val) {
print($key." ---- ".$val."<br>\n");
}
Cheers
Nick