Re: Question about replacing \r\n with <br>
| From: | John Taylor-Johnston | Date: | Sun, 23 Feb 2003 08:34:47 +0000 |
| Subject: | Re: Question about replacing \r\n with <br> | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-136704@lists.php.net to get a copy of this message | ||
I think this is what you want?
http://www.php.net/manual/en/function.nl2br.php
John
Al wrote:
> I can't find a way to replace \r\n codes with <br> in a text file.
>
> I'm reading a text file that was prepared with windows notepad
> The hex code shows OD OA for CR/LF as I expect.
>
> I'd like to replace the OD/LF with <br>s.
>
> I spent hours trying every User Notes in the PHP Manual for this simple
> operation. e.g.,
>
> $txt= preg_replace("\r\n", "<br>", $words);
>
> and this version
> $txt = preg_replace("/(\015\012)|(\015)|(\012)/","<br />", $txt);
>
> I can substitute other characters and dec equivalents and the
> substations just won't work for \r\n [or just \r or just \n] or "\015"
> or "\15".
>
> And, I've tried using "10" and "010" and "13" and
> "013".
>
> And nl2br doesn't work either.
>
> Can anyone help?
>
> Thanks........
--
John Taylor-Johnston
-----------------------------------------------------------------------------
"If it's not open-source, it's Murphy's Law."
' ' ' Collège de Sherbrooke:
ô¿ô http://www.collegesherbrooke.qc.ca/languesmodernes/
- Université de Sherbrooke:
http://compcanlit.ca/
819-569-2064