How to Remove Duplicate New Lines in PHP

The str_replace function in PHP lets you remove any character from a Web page. The br tag denotes a new line in PHP and HTML pages. You can dynamically remove extra br tags at the end of a PHP-created website so that you do not have a very long footer below the page content.

Instructions

    • 1

      Right-click the PHP file you want to edit and select "Open With." Double-click your PHP editor to open it on the desktop.

    • 2

      Scroll down the code until you reach the location where you want to type the str_replace function feature. You can use the function anywhere between "<?php" and "?>" tags, which denote the location of the PHP code.

    • 3

      Type the following code to remove excess new-line breaks:

      $newcode = str_replace('<br />', "", $php_text);

      This code strips the "<br />" tags from the $php_text variable that contains your website's code.

Related Searches:

References

Comments

You May Also Like

Related Ads

Featured