0

Im trying to save a html code

<p>fasdfasdf</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>

when i save it in mysql it is save like this also

<p>fasdfasdf</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>

how can i get rid of all line break so it will save like this

<p>fasdfasdf</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p>
Snippet
  • 1,522
  • 9
  • 31
  • 66
  • possible duplicate of [Removing line breaks (no characters!) from string retrieved from database](http://stackoverflow.com/questions/10757671/removing-line-breaks-no-characters-from-string-retrieved-from-database) – d.yuk Mar 14 '14 at 04:09

1 Answers1

2

You could easily remove all new lines ("\n") by using php's str_replace function:

$clean_string = str_replace("\n", "", $html_code);

For more info look at the following: http://php.net/str_replace.

Hope that helps!

Jlennon321
  • 263
  • 1
  • 2
  • 9