Wednesday 1 June 2016

How to remove extra Spaces, Tabs and Line feeds in php?

<?php

$string ="<b>About PHp</b>

Originally created by Rasmus      Lerdorf in 1994, the reference implementation of PHP (powered by the Zend Engine) is now produced by The PHP Group. While PHP originally stood for Personal Home Page,


it now stands for PHP: Hypertext Preprocessor, which is a recursive backronym.";

$new_string= preg_replace("/\s+/", " ", $string);

echo $new_string;

?>

Output:-  About PHp Originally created by Rasmus Lerdorf in 1994, the reference implementation of PHP (powered by the Zend Engine) is now produced by The PHP Group. While PHP originally stood for Personal Home Page, it now stands for PHP: Hypertext Preprocessor, which is a recursive backronym.

No comments:

Post a Comment