Remove Spaces Between lines in files of php code

The easiest way to remove the lines in the PHP files or in HTML files, aspx files cold fusion file, JSP file from the Dreamweaver. Likewise, we can remove the static page space like of the HTML, XSLT, CSS, XML, Javascript, XML and other as follows:

  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 “[rn]{2,}” (without quotes) in “Find”
  7. Type “n” (without quotes) in “Replace”
  8. Press “Replace All”

We can also replace the multiple line breaks through coding the coding is as below:

$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.

Previous articleFinal Year Report on E-shopping, E-commerce with affiliation
Next articleAnimation fly image to the cart functionality in opencart 1.4, opencart 2


Please enter your comment!
Please enter your name here