Hello,

I have a few Text Area input fields when I want to allow my users to enter text with hard returns. On my process page, I am using:

$Note = addslashes(nl2br($_POST['Note']));

to convert the strings to be able to be pushed to my mySQL DB. This functions great. I, also, display the fields on a few PHP pages and everything looks great.

My problem (not really a problem - I just need to learn this), I have an EDIT page where I need to be able to update the value.

When I use:

<textarea name="Lyrics" cols="88" rows="30"><? echo $row['Lyrics']; ?></textarea>

the <br \> tags are returned.

Really, I just need an OPPOSITE function to the nl2br() that will return the string back into the text area input field the way the user inputted it before submitting it.

maybe a br2nl() function

I hope this makes sense. Thanks!

// if you're using XHTML
str_replace('<br />', "\n", $string);
// if you're using HTML
str_replace('<br>', "\n", $string);
// if you're using XHTML
str_replace('<br />', "\n", $string);
// if you're using HTML
str_replace('<br>', "\n", $string);

GREAT! Thanks! it turns out that the /n is retained in the mySQL input so used this and it worked oerfectly:

<? echo str_replace('<br />', "", $row['Lyrics']); ?>

Appreciate it!

This question has already been answered. Start a new discussion instead.