display .inc files
Moderator: General Moderators
- Sevengraff
- Forum Contributor
- Posts: 232
- Joined: Thu Apr 25, 2002 9:34 pm
- Location: California USA
- Contact:
display .inc files
Arg, i need help. I need a script that will show the contents of a dir, and only link out .inc files. I tryed making my own, but i dont know enough.
link out? you mean you want .inc files to be hyperlinks, but the others to be just text?
try looking at example 1 on
http://www.php.net/manual/en/function.opendir.php
and read this to differentiate between .inc files and the others
http://www.php.net/manual/en/function.pathinfo.php
try looking at example 1 on
http://www.php.net/manual/en/function.opendir.php
and read this to differentiate between .inc files and the others
http://www.php.net/manual/en/function.pathinfo.php
Code: Select all
<?
$yourdir = "Directory";
$dir = opendir($yourdir);
$table = "<table width="50%" border="1" align="center">";
while ($viewFile = readdir($dir)) {
if (($viewFile != ".") && ($viewFile != "..")) {
if ($viewFile =~ ".inc") {
$table .= "<tr><td><a href="$viewFile">$viewFile</a></td></tr>";
}
else {
$table .= "<tr><td>$viewFile</td></tr>";
}
}
}
$table .= "</table></td></tr></table>";
?>