[prog] php script
Tricia Bowen
tricia.bowen at gmail.com
Fri Feb 19 21:34:17 UTC 2010
You can add an if statement in the while block. Something like:
while($entryName = readdir($myDirectory)) {
if ($entryName != "index.php") {
$dirArray[] = $entryName;
}
}
--Tricia
On Fri, Feb 19, 2010 at 12:53 PM, Wolf Rising <wolfrising at gmail.com> wrote:
> This litlte php script, shows a nice directory listings and avoids
> showing any hidden files.
> Is there a way to make it also not show the listing for the index.php?
>
> Thanks,
> <?php
> // open this directory
> $myDirectory = opendir(".");
>
> // get each entry
> while($entryName = readdir($myDirectory)) {
> $dirArray[] = $entryName;
> }
>
> // close directory
> closedir($myDirectory);
>
> // count elements in array
> $indexCount = count($dirArray);
> //Print ("$indexCount files<br>\n");
>
> // sort 'em
> sort($dirArray);
>
> // print 'em
> print("<TABLE border=1 cellpadding=5 cellspacing=0 class=whitelinks>\n");
> print("<TR><TH>Filename</TH><th>Filetype</th><th>Filesize</th></TR>\n");
> // loop through the array of files and print them all
> for($index=0; $index < $indexCount; $index++) {
> if (substr("$dirArray[$index]", 0, 1) != "."){ // don't list
> hidden files <---seems like the edit would be here but I couldn't get
> it to work for not displaying index.php in the list of directory files
> print("<TR><TD><a href=\"$dirArray[$index]\">$dirArray[$index]</a></td>");
> print("<td>");
> print(filetype($dirArray[$index]));
> print("</td>");
> print("<td>");
> print(filesize($dirArray[$index]));
> print("</td>");
> print("</TR>\n");
> }
> }
> print("</TABLE>\n");
> ?>
> _______________________________________________
> Programming mailing list
> Programming at linuxchix.org
> http://mailman.linuxchix.org/mailman/listinfo/programming
>
--
-=-=-=-=-=-=-=-=-=-=-=-=-
Tricia Bowen
845.255.1875
tricia.bowen at gmail.com
-=-=-=-=-=-=-=-=-=-=-=-=-
More information about the Programming
mailing list