I am basing this code on the assumption that the value of $_SERVER['DOCUMENT_ROOT'] = c:/wamp/www, and that the images are found in /my/images/
You can simplify things by using glob():
$dir = $_SERVER['DOCUMENT_ROOT'].'/my/images/';
foreach (glob($dir."*.jpg") as $filename){
echo '<img src="/my/images/' . basename($filename) . '" alt="" />' . "\r\n";
}
Output format:
<img src="/my/images/***.jpg" alt="" />
<img src="/my/images/***.jpg" alt="" />
<img src="/my/images/***.jpg" alt="" />
...
where *** is the filename. If the file paths are incorrect, adjust them to match what they need to be to work.
Cheers (and happy new year)
NRG
EDIT: Looking at the original code snippet, do not use ereg (which is part of POSIX, which will no longer be included within the PHP core as of version 6). So I recommend learning PCRE (preg functions) instead.