Right,
I require some code to have a final array of 5 random, yet unique (to each other), values.
In my code I have set up an array and a loop to insert random numbers (between a $min and a $max value) into it. This doesn't ensure that the numbers in the array are unique however.
If comparison of the numbers found that 2 or more were the same, I could simply generate another array of random numbers and keep doing this until it is ok. This however, could be endless.
Does anyone know of a good method of putting 5 random, yet unique numbers (between $min and $max) into an array?
Hope someone can help. I guess it's more a case of an algorithm rather than coding, but I would be grateful for some help.
Incidentally, the purpose is to randomly pick 5 different random records from a large record set, to display in a site.
Cheers,
Paul