Hmmm.....
Has something to do with the random selected number pulling an indexed value that has been removed from the files array. That's what this was supposed to prevent:
if($pieces[0] != ""){
$unique_images[] = $pieces[0];
unset($files[$random]);
$counter--;
}
I tested it a few times and it looked fine. Guess I should have tested it a few more times 🙂
I'm working right now but I'll take a closer look at it tonight when I get home.
If anyone else wants to fix it, feel free 😃