Help needed

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ute
Forum Newbie
Posts: 1
Joined: Thu Aug 19, 2010 4:38 am

Help needed

Post by ute »

Hi
I need someone to write me a script that reads the contents of a folder and its subfolders and then write the content into a html file as a list of links.

I would need it asap.
If someone is interested please give me a quotation.

Thanks

Ute
User avatar
MindOverBody
Forum Commoner
Posts: 96
Joined: Fri Aug 06, 2010 9:01 pm
Location: Osijek, Croatia

Re: Help needed

Post by MindOverBody »

Here it is, play a bit, and adjust it to your needs

Code: Select all

function getDirTree( $RootPath, $Position ){ 
	if ( ( $directoryHandle = opendir( $RootPath ) ) == true ) {  
              $Position += 15;
              while ( ( $file = readdir( $directoryHandle ) ) !== false ) {
                   if ( is_dir( $RootPath . "/" . $file ) && ( $file == '.' || $file == '..' ) !== true ){   
		        echo "<div style='margin-left: " . $Position . "px; '> » <a href='" . $RootPath . "/" . $file . "'>" . $file . "</a></div>";
			getDirTree( $RootPath . "/" . $file, $Position );  
                   }
              }		
        
	}
}

// First parameter: Starting position
// Second parameter: Tree item left margin (in pixels)
getDirTree( dirname(__file__), -15 );

Post Reply