Can anyone give me a heads up on how to recurse for sub-directories please? What function can I use? I'm still kind of new at this, John
> 1) set $which_one to the directory you want to search. > 2) create a recursive funtion (many on php.net) to get all subdirectories > under it and build an array with their paths as the elements. > 3) now, take that arrary and add a foreach before the line "$directory = > opendir($which_one);" replacing "$which_one" with your foreach array > element. > <?php $counter=1; $not_found=0; $which_one="."; // use a "." to search in this directory, or type in the folder name $link = "www.glquebec.org"; // this is your base url //$search_for="Search for something here!!!"; // comment this whole line out if you are using a form to search $search_for="nice word"; $directory = opendir($which_one); while($file = readdir( $directory)){$file_ar[] = $file;} foreach( $file_ar as $file ) { $type= strrchr($file,'.'); $name=$which_one; $name.="/"; $name.=$file; $file_name=fopen($name,"r"); $bleh =""; # if ($type==".php" || $type==".txt" || $type==".html") # if ($type==".htm" || $type==".txt" || $type==".html") if ($type==".htm" || $type==".html") { while ((!feof($file_name))) { $bleh .= fgets($file_name , 20000); } $bleh = strtolower($bleh); $bleh = stripslashes($bleh); $bleh = str_replace("<br>"," ", $bleh); if (stristr($bleh,$search_for)) { echo "$counter .) <a href=$link".$name.">".$link.$name."</a><br>"; echo "\"..."; $bingo = strstr($bleh, $search_for); $bingo = explode (" ", $bingo); echo "<b>$bingo[0]</b>"; for ($x=1;$x<15;$x++) echo "$bingo[$x] "; echo "...\"<br><Br>"; $counter++; $not_found=2; } else{} } fclose($file_name); } if ($not_found==0) { echo "Sorry... $search_for was not found!!!<Br> <a href=javascript:history.go(-1)>Search Again</a>"; } ?>