Unless the filenames are related to each other, e.g.
kittens.jpg -> kittens_thumb.jpg
where the extra stuff (_thumb
) is constant, there is nothing you can do in an automated fashion like this. You'd have to manually build a list that relates the images to their thumbnails. Once you've got that array, THEN you can use a simple foreach().
With the "related" filenames, you could do something like:
foreach($files as $file) {
$base = pathinfo($file, PATHINFO_BASENAME);
$ext = pathinfo($file, PATHINFO_EXTENSION);
echo "real file: $base.$ext";
echo "thumb nail: {$base}_thumb.$ext";
}