RE: [PHP-DB] newlines to BR tag
| From: | Tom Crimmins | Date: | Sat, 02 Oct 2004 16:05:05 +0000 |
| Subject: | RE: [PHP-DB] newlines to BR tag | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-36547@lists.php.net to get a copy of this message | ||
Murat BIYIKLI wrote:
>if there are unknown number of newlines
>repeating like (\r\n\r\n\r\n) in a post
>var and if I want to change them to a
>SINGLE newline, what kind of an iteration
>should be used? The >message may like below
>in DB and as you see the \r\n newline codes
>may repeat severaltimes and should be changed
> to only one SINGLE newline and after read
>from DB it will be easily coverted to BR tag
>by nl2br($foo) func.
Instead of using nl2br you could just use
$foo=preg_replace("/(\r\n)+/","<br>",$foo).
---
Tom Crimmins
Interface Specialist
Pottawattamie County, Iowa