note 97374 deleted from function.str-replace by cmb
| From: | cmb@php.net | Date: | Sun, 15 Sep 2019 14:47:30 +0000 |
| Subject: | note 97374 deleted from function.str-replace by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-212209@lists.php.net to get a copy of this message | ||
Note Submitter: fleshgrinder at gmx dot at
----
Fast function to replace new lines from a given string. This is interesting to replace all new lines
from e. g. a text formatted in HTML retrieved from database and printing it without the unnecessary
new lines. This results in slightly faster rendering in the Web browser.
<?php
/**
* Replace all linebreaks with one whitespace.
*
* @access public
* @param string $string
* The text to be processed.
* @return string
* The given text without any linebreaks.
*/
function replace_newline($string) {
return (string)str_replace(array("\r", "\r\n", "\n"), '',
$string);
}
?>