how do I exclude non-folders files from this readdir function?

krote

New Member
The following lists the folders, the index.php and the favicon.ico in the directory. I want to see only folders.Any ideas?Thanks.\[code\] <?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='http://stackoverflow.com/questions/3713588/$dirArray[$index]'>$dirArray[$index]</a></td>"); print("</tr>\n"); } } print("</table>\n"); ?>\[/code\]
 
Top