If I'm reading this correctly, you want the numbers 0-32 in a random order? If so, what you have is not the way to go. What you want to do is shuffle; otherwise, as you've seen, you could go on forever and not complete.
Update: There are some good replies below but I'm I the only one having a problem with
while the comments about 4 never getting into the list if 14 is all ready in the list are valid ... there's also the quite real possiblity of 4 never being returned from rand! Or at the very least you may get a large number of duplicate 14s before you ever get the chance to grep (validly) for 4. Shuffling is definitely what you want if what you want is 0-32 in a random order.while(1) { $rand = int(rand(32)); ... }
In reply to Re: How much random is rand()?
by derby
in thread How much random is rand()?
by gmoque
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |