Re: How to detect CR
| From: | Andy Hoffman | Date: | Tue, 10 Oct 2000 14:02:11 +0000 |
| Subject: | Re: How to detect CR | ||
| References: | 1 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-3100@lists.php.net to get a copy of this message | ||
"CESBRON S." wrote:
> I've got a database field which is field with data, that come from a
> TEXTAREA input. It contains therefore some CR. What I to do, is to be able
> to display it as it was entered. This means with the CR.
> The problem is that I couldn't detect the CR to put a <br> tag.
>
> Does anyone know how to do it ?
I'd change all newlines into <br>s when updating the database using regular
expressions or using str_replace function... in this case (to avoid increasing
#s of <br>s on every update) I'd recommend using ereg_replace.
Search for the following regular expression...
/(<br>)*\n(<br>)*/ --- perl syntax
and simply replace with...
<br>
Call to ereg_replace would look like...
ereg_replace("(<br>)*\n(<br>)*", "<br>", $sourceString);
--
Andy Hoffman
Web Developer
Bristol-Myers Squibb
email: andy.hoffman@bms.com