CodeCharge Studio
search Register Login  

Visual PHP Web Development

Visually Create Internationalized Web Applications, Web Reports, Calendars, and more.
CodeCharge.com

YesSoftware Forums -> Archive -> GotoCode Archive

 Replace /n <br>

Print topic Send  topic

Author Message
Steven
Posted: 10/21/2002, 7:19 PM

I have two large text area's in a page , and needed to clean
the page breaks text etc
so i took a look through a few of the sample CC2 codes
and found that in the gotocode example the inputted /
displayed text was being cleaned with

$fldxxxxxx = str_replace("\n", "<br>", $fldxxxxxxxxx );

so i tried it , and it worked ..... untill i clicked 'update' and it
went pearshaped, it doubled up on all the <br>'s

so what was previously:

text like this in a line
<br>with a leading break beforit
<br>like this example text

has become text that is
<br><br>formatted like this with two
<br><br>leading breaks befor each line

and if i clicked update again it gets worse
<br><br><br>it will keep adding these extra break
<br><br><br>tags for ever,

anyways, now you have had a good laugh , what can i add
to clean the html that doesnt add extra breaks on update

i did some testing and the following

$fldnews_top = str_replace("<br><br>", "", $fldnews_top );
$fldnews_top = str_replace("<br>", "", $fldnews_top );
$fldnews_top = str_replace("\n", "<br>", $fldnews_top );

works perfectly to remove all the existing 'many' <br> tags
and doesnt add any extra, so the page looks ok,

but damn thats a bad way to do it, even i can see that, so
how do i clean many breaks from my old website posts ,
but not totally kill the site by removing 'all' the <br> tags

thanks

Steven Dowd
feha
Posted: 10/21/2002, 11:58 PM

You should use this only before showing your text from the textarea to label.
(You will preserve dhe text as is ans convert only while showing it.)
To make even better formating of your text you can use this function:

$newtext = wordwrap( $text, 20, "<br>" );

regards
feha
www.vision.to
Steven
Posted: 10/22/2002, 2:54 AM

If I show the text from the atabase into a textarea field in the form using in the befor show event, the mentioned

$fldxxxxxx = str_replace("\n", "<br>", $fldxxxxxxxxx );

then on update this textarea content is saved with ethe <br>'s

then when updated again it adds another and another and another
how do i get round that?

feha
Posted: 10/22/2002, 4:30 AM

Please read above...
Don't use this functions while editing or inserting text in to text area...
use just when you want to display them on the LABEL.



regards
femi

   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

PHP Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.