The script itself works just fine, no problems there. The problem is that the shuffle() doesn't seam to really be random. I keep getting the same results at a rate that makes me think this function is no good. The original array has 2727 entries but about 20 files have a tendency to always show up in the 5 random results. I know for sure because with the rate that I use this script, it should take me hundreds of runs to get the same result twice but I had 3 entries show up twice in 3 runs. Crazy annoying.
My code is thus:
Code: Select all
shuffle($shows);//$shows has the 2727 entries
$playlistShows = array();//just trying to get 5 results in the end
for ($i = 0; $i < registry::fetchKey('playlistSize'); $i++)
{
$playlistShows[] = $shows[$i];
unset($shows[$i]);
shuffle($shows);
}Is there a better way to get 5 random results out of an array that large? I have a tendency to run the script at the same time every day (before I go to bed) so if it somehow took the current time of some sort as the seed then maybe that has something to do with it? Maybe I am just going insane?