exploring folders

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
User avatar
itsmani1
Forum Regular
Posts: 791
Joined: Mon Sep 29, 2003 2:26 am
Location: Islamabad Pakistan
Contact:

exploring folders

Post by itsmani1 »

Code: Select all

<?
function read_dir($dir) {
   $array = array();
   $d = dir($dir);
   while (false !== ($entry = $d->read())) {
       if($entry!='.' && $entry!='..') {
           $entry = $dir.'/'.$entry;
           if(is_dir($entry)) {
               $array[] = $entry;
               $array = array_merge($array, read_dir($entry));
           } else {
               $array[] = $entry;
           }
       }
   }
   $d->close();
   return $array;
}
	$abc = array();
	$abc = read_dir("abc");
	for($i=0; $i<=sizeof($abc); $i++)
	{
		echo $abc[$i]."<BR>";
	}
?>

abc/abc.htm
abc/jk
abc/jk/pop.htm
abc/xyz.htm


now i want to access files seprately, and i want to browse folders? Pleae helo how can i do so?

thanks.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

you already have the answer: is_dir() .. and is_file()
Post Reply