<?PHP/********************** A simple directory recursive function The first implementation of the method: Return the object with dir ***********************/functionTree$directory) { $mydir=dir($directory); Echo"<ul>\n"; while($file=$mydir-Read ()) { if((Is_dir("$directory/$file")) and ($file!=".") and ($file!="..")) { Echo"<li><font color=\" #ff00cc \ "><b>$file</b></font></li>\n "; Tree ("$directory/$file"); } Else Echo"<li>$file</li>\n "; } Echo"</ul>\n"; $mydir-close ();} //Start RunningEcho"; Tree ("./nowamagic"); /*********************** The second method of implementation: with the Readdir () function ************************/functionListdir ($dir){ if(Is_dir($dir)) { if($DH=Opendir($dir)) { while(($file=Readdir($DH)) !==false) { if((Is_dir($dir." /".$file)) &&$file! = "." &&$file!="..") { Echo"<b><font color= ' red ' > FileName:</font></b>",$file, "<br>; Listdir ($dir." /".$file." /"); } Else { if($file! = "." &&$file!="..") { Echo $file." <br> "; } } } Closedir($DH); } }}//Start RunningListdir ("./nowamagic");?>