Posted by windandwaves on 10/01/88 11:42
windandwaves wrote:
> Hi Folk
>
> I want a random list of numbers between 0 and 58 where each number
> can only occur once. I have written this ($f is an array):
>
> for($i = 0; $i < 13; $i++) {
> $rand[$i] = mt_rand(0,count($f));
> }
>
> what else do I need?
>
> TIA
>
>> Nicolaas
This is what I came up with:
for($i = 0; $i < 12; $i++) {
$r[$i] = mt_rand(0,count($f));
for($j = ($i - 1); $j > -1; $j--) {
if($r[$j] == $r[$i]) {
$i = 0;
}
}
}
but it does not seem to work
Any suggestions?
TIA
> Nicolaas
[Back to original message]
|