First off, you assign dir->read() to $entry, but then uses the undefined variable $dirEntry. After that, I'd recommend ditching string interpolation for your array values, since these two statements are equivalent, but the string version requires extra work
"{$array['key']}"; // string interpolation - extra work
$array['key']; // the exact same thing - no extra work needed
Your usage of str_replace seems weird as well. When you get to the file 11601thumb.jpg, you will have
(search) $placeholders = array('11601thumb.jpg');
(replace) $thumbvals = array('<img src="play/play.png" style="width: 20px; height: 20px">');
(subject) $rawstring = '11601thumb.jpg';
So, to begin, you will always only have one array element, which makes using arrays pointless. You could just as well use the value directly instead. Moreover, in the string '11601thumb.jpg' you want to replace the string '11601thumb.jpg' with the string '<img src="play/play.png" style="width: 20px; height: 20px">'.
In other words, you could just as well use the string '<img src="play/play.png" style="width: 20px; height: 20px">' straight away.
But, if my guess is correct, what you want is '<img src="play/thumb11601.jpg" style="width: 20px; height: 20px">'. And if that is the case, you could build this string directly
printf('<img src="play/%s" style="width: 20px; height: 20px">', $file['name']);
Since you have index.php in your directory listing, I'm guessing this is the docroot of your web server. Personally I like keeping different types of resources separated, so I'd move all images to ./images, and if you have multiple versions go with something like images/full_size and images/thumbs.
If you split up your files according to such a hierarchy, you could also keep the exact same filename, extension excluded, for all your files. I.e.
products/descriptions/11601.txt
products/images/full/11601.jpg
products/images/thumbs/11601.jpg
Assuming all of your products will always have a description, or a thumbnail, you could simply go over the entire descriptions directory, or thumbnail directory, and this way extract all the information you need. Something along the lines of
function getNames($dir)
{
if (false === ($d = dir($dir)))
{
return false;
}
$names = array();
while (false !== ($f = $d->read()))
{
if ($f[0] != '.')
{
printf('<div>%s</div>', $f);
$names[] = substr($f, 0, -4);
}
}
return $names;
}
$baseDir = 'products/';
$descDir = $base.'descriptions/';
$fullDir = $base.'/images/full/';
$thumbDir = $base.'/images/thumbs/';
$products = getNames('products/descriptions');
if ($products === false)
{
echo 'Error retrieving product data';
exit;
}
foreach ($products as $p)
{
printf('<h3>%s</h3><div><img src="%s%s" alt="" /></div><p>%s</p><br />',
$p, /* product name */
$thumbDir, /* thumbnail directory */
$p.'.jpg', /* image thumbnail */
$descDir.$p.'.txt' /* product descrition */
);
}
And then, in the last printf statement, you'd obviously change the <img ... > into <img ...> to actually display the image. Along the same lines, you'd change $descDir.$p.'txt' to file_get_contents($descDir.$p.'txt');
It may also be a good idea to add code to check that all files actually exist so that you for example might display "No description" if there is no file in products/descriptions.