PHP - removing CR in html textarea
Posted: Wed Jan 04, 2012 10:57 am
Hi everyone,
I have an issue with a text area in an html form. When data is retrieved from a mysql database, the message area displays 'br '. I can use str_replace, which could eliminate the 'br ', but the message area still assumes there is a CR.
Does anyone have any ideas on how to resolve this issue?
This is the coding I'm using to remove any variation of 'br', however there are still line breaks on every line and there shouldn't be.
I have an issue with a text area in an html form. When data is retrieved from a mysql database, the message area displays 'br '. I can use str_replace, which could eliminate the 'br ', but the message area still assumes there is a CR.
Does anyone have any ideas on how to resolve this issue?
This is the coding I'm using to remove any variation of 'br', however there are still line breaks on every line and there shouldn't be.
Code: Select all
<?php
$originalmsg = $row['body'];
$contentfixed = str_replace('</p>', '</p><br />', "$originalmsg");
$contentfixed = strip_tags($contentfixed, '<br>');
$contentfixed = str_replace("<br /> <br />", "\n", "$contentfixed");
$contentfixed = str_replace("<br />", "\n", "$contentfixed");
$contentfixed = str_replace("<br>", "\n", "$contentfixed");
$contentfixed = str_replace("<br ><br >", "\n", "$contentfixed");
$contentfixed = str_replace("<br ><br ><br >", "\n", "$contentfixed");
$contentfixed = str_replace(" <br />", "\n", "$contentfixed");
?>
<textarea name="ActionTextField" cols="60" rows="30" id="ActionTextField" ><?php echo $contentfixed; ?></textarea>