Well firstly get the files from both images and thumbnail directories. Both being in different arrays so
$thumbnail etc i think thats fairly obvious from there work out which image in the images directory match up with the thumbnail array.
So maybe somthing like this
//$thumbnail is thumbnail array
//$images is image array
for ($i=0;$i<sizeof($images);$i++) {
if (!in_array($images[$i],$thumbnail)) {
//not in the array delete if nessacary
} else {
//its in the array leave or do something
}
}
The code below checks the $thumbnail array from a value from $images[$i] you can from there also check if the thumbnails match up with the $images but that isnt required
if (!in_array($images[$i],$thumbnail))
Once you have your two arrays built up its time to randomise
<?php
srand((float) microtime() * 10000000);
//we wont only one thumbnail
$randthumbNail = array_rand($input, 1);
echo $input[$randthumbNail['0']] . "\n";
Use this as a guide as i did not test this
Goodluck 🙂