I'm working on a pice of code which list all files in a directory and return the list and its content right under the name of the file.
Code: Select all
<?php
$thelist = "";
if ($handle = opendir('.')) {
while (false !== ($file = readdir($handle)))
{
if ($file != "." && $file != "..")
{
$thelist .= '<a href="'.$file.'">'.$file.'</a><br/>';
$contents = file($file);
$string = implode($contents);
$thelist .= '<p>'.$string.'</p>';
}
}
closedir($handle);
}
?>
<P>List of files:</p>
<P><?=$thelist?></p>
I'm looking for a way of choose only 3 or 4 extension only.
How would I dow so ?
Thanks !