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 Quote Link to comment 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. Quote Link to comment 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" Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.