View Single Post
Old 10-23-2008, 11:11 PM   #4 (permalink)
Salathe
Moderateur
RegEx Guru PHP Guru Top Contributor Advanced Programmer 
 
Salathe's Avatar
 
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
Salathe is on a distinguished road
Default

Quote:
Originally Posted by paulOr View Post
this code allows me to show 5 random links, however when it loads, sometimes there is like:
Proxy #1
Proxy #1
Proxy #1
Proxy #3

true enough, its random but i dont want dupliates
Using the code that you provided, there shouldn't be any duplicates (unless you have duplicates in the original array). Running this code a million times, there's not even one duplicated value (from a quick test) which confirms my suspicion.

If you're wanting another approach, copy the original array into a new temporary variable. Then, shuffle it and array_slice however many you want.
Salathe is offline  
Reply With Quote