10-23-2008, 11:11 PM
|
#4 (permalink)
|
|
Moderateur
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
|
Quote:
Originally Posted by paulOr
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.
|
|
|
|