https://fonts.googleapis.com/css?family=Raleway

"Complex Problems, Solved Quickly"

RCH Tech Solutions
  • Home
  • About
    • Services
  • Products
    • Visitor Logic Pro
    • Engage Theme For WordPress
    • WishList Member Upsell WordPress Plugin
  • Portfolio
  • Articles
    • Apache
    • Subversion
    • PHP
    • jQuery
    • WordPress Solutions
    • Exim
  • Members Dashboard
    • License Details
    • Support
Main Menu
  • Home
  • About
    • Services
  • Products
    • Visitor Logic Pro
    • Engage Theme For WordPress
    • WishList Member Upsell WordPress Plugin
  • Portfolio
  • Articles
    • Apache
    • Subversion
    • PHP
    • jQuery
    • WordPress Solutions
    • Exim
  • Members Dashboard
    • License Details
    • Support
  • License Details
  • Support

Post navigation

PHP |

April 9, 2013

| by Rodger Hollingsworth

Simple PHP script to create a nice listing of directories only

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<div style="width: 600px; margin: 50px auto">
<h1>Directory Listing</h1>
<?php 
// Your start directory
getDirectory(dirname(__FILE__));
function getDirectory( $path = '.', $level = 0 )
{ 
// Directories to ignore when listing output. 
$ignore = array( '.', '..' );
// Open the directory to the handle $dh
$dh = @opendir( $path );
// Loop through the directory 
while( false !== ( $file = readdir( $dh ) ) ) 
{ 
// Check that this file is not to be ignored 
if( !in_array( $file, $ignore ) )
{ 
// Indent spacing for better view
$spaces = str_repeat( '&nbsp;', ( $level * 5 ) );
// Show directories only
if(is_dir( "$path/$file" ) )
{ 
// Re-call this same function but on a new directory. 
// this is what makes function recursive. 
echo "$spaces<a href='$path/$file/index.php'>$file</a><br />";
//uncomment the following line to display multiple levels of directories.
//getDirectory( "$path/$file", ($level+1) ); 
} 
} 
}
// Close the directory handle 
closedir( $dh ); 
} 
?>
</div>
</body>
</html>
Comment

Post navigation

Older Newer
Google+ comment widget by skipser

Menu

  • Home
  • About
    • Services
  • Products
    • Visitor Logic Pro
    • Engage Theme For WordPress
    • WishList Member Upsell WordPress Plugin
  • Portfolio
  • Articles
    • Apache
    • Subversion
    • PHP
    • jQuery
    • WordPress Solutions
    • Exim
  • Members Dashboard
    • License Details
    • Support

Recent Posts

  • SVN checkout to an existing live folder
  • jQuery Ajax with .html() does not fire js code
  • Installing and setting up Subversion on a WHM/Cpanel server
  • WHM Exim Configuration send mail with Amazon SES
  • WordPress Engage
  • UNIFFI
  • Gung-Ho
  • AthleanX
  • Collier County Fair
  • Simple PHP script to create a nice listing of directories only

Menu

  • Home
  • About
  • Products
  • Services
  • Portfolio
  • Contact Us

Products

Engage Theme For Wordpress

WLM Upsells Wordpress Plugin

Support

footer-logo

© RCH Tech Solutions 2017

Lost your Password

OR