I want to add exactly 5 random numbers to an array, but each number must be different. Here is what I have so far...
$col_B = array();
for ($i=1; $i < 6; $i++) {
$rand = $col_ranges['B'][rand ( 0 , 14 )]; // calls to an array of numbers
if(!in_array($rand, $col_B)){
$col_B[] = $rand;
}
else{ $i - 1;}
}
echo implode($col_B, '<br>');
Aucun commentaire:
Enregistrer un commentaire