Click to See Complete Forum and Search --> : [RESOLVED] Help removing <br /> from a text box


bfulda
01-16-2007, 10:55 AM
Hey all,

When I use this code (below) all of the text is formated correctly:

echo '<br />Description: <br />';
echo nl2br(stripslashes($row['description']));
echo '</p><br />';

But when I want to put the text into a textbox with this:

echo '<br />Description: <br />';
echo nl2br('<textarea rows="15" cols="80" "12">');
echo nl2br(stripslashes($row['description']));
echo nl2br('</textarea>');
echo '</p><br />';

I get output that shows all of <br />'s like so:

There is no patch. The alert says there is no workaround at this time.<br />
<br />
Glenn <br />
<br />

Any ideas on how to overcome this?
Thanks!!
brad dot fulda at logsa dot army dot mil

NightShift58
01-16-2007, 11:12 AM
Use str_replace("<br />", "", stripslashes($row['description'])).
echo '<br />Description: <br />';
echo '<textarea rows="15" cols="80" "12">';
echo str_replace("<br />", "", stripslashes($row['description']));
echo '</textarea>';
echo '</p><br />';

chickenland
01-16-2007, 11:33 AM
nl2br replaces all newline characters with <br /> tags (or <br>) whereas I assume you already have the <br /> tag in your DB?

Use what NightShift58 recommends above, or Use str_replace("<br />", "\n", stripslashes($row['description'])) to put them back in.

bfulda
01-16-2007, 12:28 PM
The the str_replace works great!! Thanks for the quick reply. I appreciate the help.

Brad

NightShift58
01-16-2007, 12:32 PM
You're welcome!