A glob would probably be a bit easier to work with for this.
PHP Code:
if (isset($_GET['searchFile']) && false !== filter_var($_GET['searchFile'], FILTER_VALIDATE_INT))
{
$sSearch = '/path/to/images/' . (int)$_GET['searchFile'] . '*';
$aFiles = glob($sSearch);
foreach ($aFiles AS $file)
{
echo "<a href='".$file."'>'".$file ."'</a>";
}
}
Looks like it would work. I assume that searchFile will always be a number and validated it as such. Never allow a path to enter your search criteria, but if you need a string, you can always encode the / first so at least it would fail instead of granting access to higher level directories.
There are also iterators you can work with, including the globiterator and regexiterator. The glob iterator usage is almost identical to the glob, and the regexiterator would be used in conjunction with a filesystem or directory iterator.