Converting <br /> into a new line for use in a text area

In PHP, you can use the nl2br() function to convert line breaks (\n or \r\n) to <br /> tags. To convert <br /> tags back to line breaks in a text area, you can use the str_replace() function.

Here is an example:


$text = "Line 1<br />Line 2<br />Line 3";
$text = str_replace("<br />", "\n", $text);

echo $text;

Watch a course Learn object oriented PHP

This will replace all instances of <br /> with a new line character, so that the text can be displayed correctly in a text area.