note 130104 added to function.nl2br
| From: | internmail@gmail.com | Date: | Sat, 01 Mar 2025 13:07:39 +0000 |
| Subject: | note 130104 added to function.nl2br | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-221930@lists.php.net to get a copy of this message | ||
/**
* Converts multiple consecutive blank lines into a single blank line
* and replaces all remaining line breaks with <br /> for HTML output.
* @see https://www.php.net/manual/en/function.nl2br.php
*
* @param string $string The input string containing line breaks
* @return string The processed string with HTML line breaks
*/
function nl2br2($string) {
/* Replaces several consecutive blank lines with a single blank line */
$string = preg_replace("/(\r\n|\r|\n){2,}/", "\n", $string);
/* Replaces remaining line breaks with <br /> */
return str_replace(array("\r\n", "\r", "\n"), "<br
/>", $string);
}
----
Server IP: 45.112.84.4
Probable Submitter: 80.90.5.137 (proxied: 2003:de:4709:1300:c017:c33e:1963:7cde)
----
Manual Page -- https://php.net/manual/en/function.nl2br.php
Edit -- https://main.php.net/note/edit/130104
Del: integrated -- https://main.php.net/note/delete/130104/integrated
Del: useless -- https://main.php.net/note/delete/130104/useless
Del: bad code -- https://main.php.net/note/delete/130104/bad+code
Del: spam -- https://main.php.net/note/delete/130104/spam
Del: non-english -- https://main.php.net/note/delete/130104/non-english
Del: in docs -- https://main.php.net/note/delete/130104/in+docs
Del: other reasons-- https://main.php.net/note/delete/130104
Reject -- https://main.php.net/note/reject/130104
Search -- https://main.php.net/manage/user-notes.php