The easiest way to remove the lines in the PHP files or in HTML files,
- Open the file
- Click CTRL + F
- Select “Current document” in “Find in” (You can also select the folder if you have multiple files)
- Search in “Source code”
- Tick “Use regular expression”
- Type “[rn]{2,}” (without quotes) in “Find”
- Type “n” (without quotes) in “Replace”
- Press “Replace All”
We can also replace the multiple line breaks through coding the coding is as below:
<?php
$base = array("f:/www/docs/files/");
while (!empty($base)) {
$next = array_pop($base);
foreach (glob($next . '*.php') as $item) {
if (!is_dir($item)) {
file_put_contents($item, preg_replace(array("#^s*r?n+#s", "#s*r?n+$#s", "#s*r?n+#s"), array("", "", "rn"), file_get_contents($item)));
} else {
$base[] = $item . '/';
}
}
}
echo "Removing extra lines is done";
?>
These are the two methods by which we can remove the extra lines.