Showing random links with an array
View Single Post
10-23-2008, 11:11 PM
Join Date: Apr 2007
Originally Posted by
this code allows me to show 5 random links, however when it loads, sometimes there is like:
true enough, its random but i dont want dupliates
Using the code that you provided, there
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.
View Public Profile
Send a private message to Salathe
Visit Salathe's homepage!
Find More Posts by Salathe