Re: Editing in a text area field

From: Date: Fri, 09 Jan 2009 16:58:41 +0000
Subject: Re: Editing in a text area field
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-285854@lists.php.net to get a copy of this message
On Fri, Jan 9, 2009 at 11:15, Stephen <stephen-d@rogers.com> wrote: > > Thank you! That is the way I will do this. > > I may want to change <br /><br /> to </p><p> but that should be easy. <?php // Convert HTML linebreak tags to paragraph tags. function br2p($str) { $str = preg_replace("/<br\s?\/?>(\r)?(\n)?<br\s?\/?>/Ui","</p>$1$2<p>",$str); return $str; } $str = "This is an example of the use of this function.<br /><br />It should replace only double <br> tags."; echo br2p($str)."\n"; $str =<<<HTML This is another example. If I place any multiple of two <br>, <br />, <BR>, <BR />, <Br>, <Br />, <bR>, or even <bR /> tags side-by-side, they should be replaced with <p></p>. In addition, if there is a newline character in *NIX, Windows, or old-style Mac/Amiga, this will be carried over in the translation. This will ensure preservation of all but the <br /> tags. HTML; echo br2p(nl2br($str)); ?> -- </Daniel P. Brown> daniel.brown@parasane.net || danbrown@php.net http://www.parasane.net/ || http://www.pilotpig.net/ Unadvertised dedicated server deals, too low to print - email me to find out!

« previous php.general (#285854) next »