I am using textarea to save content in mySQL DB and using nl2br
to preserve line breaks used by user.
PHP method of using nl2br
$description = safe_var($_POST['description']);
$text = preg_replace('#[
]+#', "
", $description);
$description_html = nl2br($text);
Now, when i am using edit option of update the description
then there is a new <br/>
added everytime i press update button.
It means that if first time my content looks like as below
Line 1
-----one space
Line 2
----- One space
Line 3
And then if i update this content with some words then i get output like as below and this is not expected
Line 1
-----one space
-----one space
Line 2
----- One space
-----one space
Line 3
-----one space
Line 4
Is there any way to prevent new lines to already added spaces until unless user gives a space.