Aug 13

Sometimes you get awful lots of line spacing after you download a file from the server.
It’s really annoying to delete one by one and it takes your valuable time do that. I was searching for a easy way to fix this and found a solution in the following forum.
http://forums.digitalpoint.com/showthread.php?t=622323

This is how you do it (as for nico_swd’s post)

  1. Open the file
  2. Click CTRL + F
  3. Select “Current document” in “Find in” (You can also select the folder if you have multiple files)
  4. Search in “Source code”
  5. Tick “Use regular expression”
  6. Type “[\r\n]{2,}” (without quotes) in “Find”
  7. Type “\n” (without quotes) in “Replace”
  8. Press “Replace All”
Oct 22

This function is developed using simple php. This will not work in dynamic contents because it’s searches the file; line by line in the server end. If you have a website with lots of static html pages I think you will find this very useful. One of the down side is even if you have a html comment in the file it’ll search that as well.

 

HTML Form:

<form action=”test_search.php” method=”post” name=”d”>
<input name=”send” type=”hidden” value=”1″ />
<input name=”term” type=”text” />
<input name=”submit” type=”submit” value=”submit” />
</form>

 

PHP Code:

 

<?php
//this fucntion is used to get the tile tag of the page
function get_title($a,$b,$c){
$y = explode($b,$a);
$x = explode($c,$y[1]);
return $x[0];
}

 

//if form is submited do the following

if(isset($_POST['send'])){
if ($handle = opendir(‘/path to your directory/’)) { //example path  /home/site-user-name/public_html/my-folder/
 // lets loop over the directory.
 $i=0;
 while (false !== ($file = readdir($handle))) {
     if ($file != “.” && $file != “..”) {
   $page= ‘myfolder/’.$file;
   $page= file ($page);
   $numtlines = count ($page); //Number of lines in the file
   
   $line = 0;
   while ($line < $numtlines) {
    if(stristr ($page[$line], ”.$_POST['term'].”)){ //found a match

     //let’s get the page title
     echo ‘<br><a href=”http://www.url-to-your-file/’.$file.’”>”‘.get_title(file_get_contents(‘http://www.url-to-your-file/’.$file), “<title>”, “</title”).’</a><br>’;
     $metatagarray = get_meta_tags(‘http://www.url-to-your-file/’.$file);
     echo $description = $metatagarray[ "description"];
     $line = $numtlines;
    }
    $line++;
   }
     }
 $i++;
 }
closedir($handle);
}
}

?>

Copyright ©Web Design Help. Proudly powered byWordPress
Web Design Website Design Web Design Melbourne Web Hosting