Re: Swapping <BR> for \n... ?
| From: | Daniel Grace | Date: | Wed, 30 Jan 2002 06:54:39 +0000 |
| Subject: | Re: Swapping <BR> for \n... ? | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-82685@lists.php.net to get a copy of this message | ||
"Jon" <Jon@digital-explosion.co.uk> wrote in message
news:20020130043554.7719.qmail@pb1.pair.com...
> Nevermind, I found some code at last which actually works :
>
> $txt = preg_replace("/(\015\012)|(\015)|(\012)/","<BR>",$txt);
>
rather than using a regular expression, try:
$txt = strtr($txt, array("\r\n" => "<br />", "\n" =>
"<br />", "\r" => "<br
/>"));
This is probably faster, see http://www.php.net/strtr for
details.