The following lists the folders, the index.php and the favicon.ico in the directory. I want to see only folders.
Any ideas?
Thanks.
<?php
// opens this directory
$myDirectory = opendir(".");
// gets each entry
while($entryName = readdir($myDirectory)) {
$dirArray[] = $entryName;
}
// closes directory
closedir($myDirectory);
// counts elements in array
$indexCount = count($dirArray);
// sorts files
sort($dirArray);
// print 'em
print("<table width='100%' cellspacing='10'>
<tr>
</tr>\n");
// loops 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
print("<tr><td><a href='$dirArray[$index]'>$dirArray[$index]</a></td>");
print("</tr>\n");
}
}
print("</table>\n");
?>
Use the following:
I however suggest to use
glob()
for this kind of operation. e.g.: