PHP list of specific files in a directory
- by Jessica
The following code will list all the file in a directy
<?php
if ($handle = opendir('.')) {
while (false !== ($file = readdir($handle)))
{
if ($file != "." && $file != "..")
{
$thelist .= '<LI><a href="'.$file.'">'.$file.'</a>';
}
}
closedir($handle);
}
?>
<P>List of files:</p>
<UL>
<P><?=$thelist?></p>
</UL>
While this is very simple code it does it job.
I'm now looking for a way to list ONLY file that have .xml (or .XML) at the end, how do I do that?
Code is appreciate, thanks!
jess