rvdb86 Posted July 25, 2009 Share Posted July 25, 2009 Hi I hope someone can help me with this: I am pulling a text result for the database and using it in javascript. Inorder for the javascript to work there must not be any line breaks in the string. However, because it is a text value that id being used i do need the text to show up properly. I tried using nl2br but that just added br before the line break. heres an example of what i need: from: <div><span>2009-07-24</span><p>text<br /> text, text text</p></div> to: <div><span>2009-07-24</span><p>text<br />text, text text</p></div> I would really appreciate any suggestions! TIA Link to comment https://forums.phpfreaks.com/topic/167347-remove-line-break-in-code/ Share on other sites More sharing options...
xtopolis Posted July 25, 2009 Share Posted July 25, 2009 str_replace on the line endings? depending what type of endings they are you could probably str_replace("\\n", '', $textInput) \\n would be whatever line endings they are. Link to comment https://forums.phpfreaks.com/topic/167347-remove-line-break-in-code/#findComment-882453 Share on other sites More sharing options...
xtopolis Posted July 25, 2009 Share Posted July 25, 2009 looks like it should just be "\n" to replace not "\\n" Link to comment https://forums.phpfreaks.com/topic/167347-remove-line-break-in-code/#findComment-882456 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.