Jump to content

replacing linebreak


Ustag

Recommended Posts

Hi I have a text field that when people add it to my database text and linebreaks looks like this in the db:

Hinextnext
With nl2br() it looks like this:
hi <br><br>next<br>next<br>
What I need is this:
hi<br><br>next<br>next<br>
Does anybody know what I can use to reach this instad of with nl2br()?
Link to comment
Share on other sites

both will do the same job.i am not sure though why you need that.

Link to comment
Share on other sites

ohh...you need to use something like..

preg_replace("/[\n]/","",nl2br($content));

or

str_replace("\n","",nl2br($content));

Link to comment
Share on other sites

I'm not sure why you'd need it all on one line, but you should be able to remove line breaks with this regular expression:JS regex: /(\r\n|\n|\r)/gmPHP regex: '/(\r\n|\n|\r)/s'Example usage:

var text = "Multiline		   text		   !"text.replace(/(\r\n|\n|\r)/gm, '');

Or PHP:

$text = "Multiline		   text		   !";$text = preg_replace('/(\r\n|\n|\r)/s', '');

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...