jaymc Posted March 3, 2009 Share Posted March 3, 2009 Whats the best way in PHP to turn this paragraph one will go here paragraph two will go here <p>paragraph one will go here</p> <p>paragraph two will go here</p> It needs to wrap <p> </p> tags around a paragraph, which should be triggered with double line break Quote Link to comment Share on other sites More sharing options...
premiso Posted March 3, 2009 Share Posted March 3, 2009 $string = str_replace("\n\n", "</p><p>", $string); $string = "<p>" . $string . "</p>"; echo $string; str_replace Quote Link to comment Share on other sites More sharing options...
jaymc Posted March 3, 2009 Author Share Posted March 3, 2009 That will cause <p>paragraph one will go here</p> <p>paragraph two will go here</p> <p></p> Wont it? Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted March 3, 2009 Share Posted March 3, 2009 its checking for a double break not a single Quote Link to comment Share on other sites More sharing options...
jaymc Posted March 3, 2009 Author Share Posted March 3, 2009 Ah yes, cool Thanks Quote Link to comment Share on other sites More sharing options...
premiso Posted March 3, 2009 Share Posted March 3, 2009 That will cause Wont it? Did you try it? Quote Link to comment Share on other sites More sharing options...
jaymc Posted March 3, 2009 Author Share Posted March 3, 2009 Yes but I had to change it to this str_replace("\r\n\r\n" \r\n\r\n to pick up the line breaks Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted March 3, 2009 Share Posted March 3, 2009 unix vs windows break lines 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.