Just a quick question abut the array_rand function. I'm trying to get 3 unique, random values from an array, and was wondering if array_rand does just that, or is there a chance of a duplicate value, as with using rand().
coopster
7:51 pm on Jan 22, 2005 (gmt 0)
what about using shuffle() [php.net] and then grab the first three indexes out of the array? At least you'll know they are all random and not repeats.
ln_tora
7:55 pm on Jan 22, 2005 (gmt 0)
Hadn't gotten to shuffle yet. Certainly doable that way, though I'm still curious about array_rand() returning duplicates. (One of those things I should know for later.)
coopster
8:13 pm on Jan 22, 2005 (gmt 0)
Maybe I misunderstood you...are you talking about passing array_rand() the optional second argument and specifying how many entries you want to pick in one shot? Then you should be fine. To the best of my knowledge, it returns unique key values.