Quantcast
Viewing latest article 4
Browse Latest Browse All 12

Simple PHP script to walk and print a directory tree

<?php
function walk_dir($dir){
	$relativedir = '.'.$dir;
	if($dh = opendir($relativedir)){
	while(false !== ($file = readdir($dh))){
		if(($file !== '.') && ($file !== '..')){
			if(!is_dir($relativedir.$file)){
				echo '<a href="'.$dir.$file.'" title="'.$file.'">'.$file.'</a>'."\n";
			}else{
				walk_dir($dir.$file.'/');
			}
		}
	}
	}
}

walk_dir('/');
?>

Tagged: direcotry walk, directory, Files, itterate, PHP, recursive, Script, sub, subdirectories, subfiles, to, walk Image may be NSFW.
Clik here to view.
Image may be NSFW.
Clik here to view.

Viewing latest article 4
Browse Latest Browse All 12

Trending Articles