Re: Help with formating text from PHP

From: Date: Sun, 10 Aug 2003 08:39:10 +0000
Subject: Re: Help with formating text from PHP
References: 1 2 3 4 5 6  Groups: php.db 
Request: Send a blank email to php-db+get-29795@lists.php.net to get a copy of this message
Budelak wrote:
You guys thanks for the encouragement. I finally solved it with this: <?php $text= preg_replace("/(\015\012)|(\015)|(\012)/","&nbsp;<br />", $rsDailynewsDetail->Fields('newsfull')); echo $text; ?> Help came of course from the link Holmes gave.
You're welcome, I think. Why didn't you just use nl2br()? If you must use a method like you're using now, then this should work better and faster: $text = str_replace(array(chr(13).chr(10),chr(13),chr(10)),'&nbsp;<br />',$rsDailynewsDetail->Fields('newsfull')); Note that the output of this and what you're using now is going to be spread out on one huge line in your HTML source because your removing the newlines. Since HTML ignores them, I don't see why they need to be removed. -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ PHP|Architect: A magazine for PHP Professionals – www.phparch.com

« previous php.db (#29795) next »