What would be a good way to generate 7 unique random numbers between 1 and 10. I can\'t have any duplicates. I could write a chunk of PHP to do this (using rand() and pushin
Check out the comments in the php manual, there are several solutions for this.
An easy one is this one:
$min = 1; $max = 10; $total = 7; $rand = array(); while (count($rand) < $total ) { $r = mt_rand($min,$max); if (!in_array($r,$rand)) $rand[] = $r; }