zachsformacs95
New Member
I have a field in a mySQL database called "bio." You edit that field with a <textarea>. I have been using the following to add line breaks:
It works fine. However, if they edit this bio, I apply the function again (in case they add any new line breaks). The problem is that it also adds new <br />s to the line breaks that have already been dealt with... So:
may become:
Is there a way around this? My first thought is to test if there are 2 or more consecutive <br />s, but there are times when I want there to be 2 consecutive <br />s (as if starting a new paragraph). Perhaps a way to remove the <br />s before applying the function again? Thanks in advance.
PHP:
$bio = ($_GET['bio']) ? $_GET['bio'] : $_POST['bio'];
$bio = nl2br($bio);
It works fine. However, if they edit this bio, I apply the function again (in case they add any new line breaks). The problem is that it also adds new <br />s to the line breaks that have already been dealt with... So:
Code:
text<br />
text
may become:
Code:
text<br /><br />
text<br />
text
Is there a way around this? My first thought is to test if there are 2 or more consecutive <br />s, but there are times when I want there to be 2 consecutive <br />s (as if starting a new paragraph). Perhaps a way to remove the <br />s before applying the function again? Thanks in advance.
Last edited: