So, I needed to read the contents of a directory, and then pick a set number of unique files, randomly. Now I can get a set of random files, but the keyword here is unique or non-repeating. The quest took me half a day, and really showed how I need to learn PHP a lot more. But what can I do, the damn language has more than 3000 functions (PERL has less than 300!). I found code that can pick one random image from a directory, but it needed moding because I wanted not one, but... lets say 9 randomly picked images. I tried all sorts of loops, stuff like:
for ( (x = getRandomImage()) && i < 10) {
if (!in_array(x,arrayx)) {
arrayx[i] = x;
i++;
}
}
$list = getImagesList();
$list2=range(1,sizeof($list));
shuffle($list);
$list2=array_slice($list2,0,9);