Good day to you all, 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. <?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> PHP: I'm looking for a way of choose only 3 or 4 extension only. How would I dow so ? Thanks !
hi where it says if ($file != "." && $file != "..") Code (markup): replace with if (eregi("txt$",$file) || eregi("jpg$",$file) || eregi("gif$",$file)) Code (markup): replace extension how you need, add more if needed. enjoy