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 Link to comment https://forums.phpfreaks.com/topic/147752-solved-paragraph-parser/ 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 Link to comment https://forums.phpfreaks.com/topic/147752-solved-paragraph-parser/#findComment-775593 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? Link to comment https://forums.phpfreaks.com/topic/147752-solved-paragraph-parser/#findComment-775598 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 Link to comment https://forums.phpfreaks.com/topic/147752-solved-paragraph-parser/#findComment-775607 Share on other sites More sharing options...
jaymc Posted March 3, 2009 Author Share Posted March 3, 2009 Ah yes, cool Thanks Link to comment https://forums.phpfreaks.com/topic/147752-solved-paragraph-parser/#findComment-775610 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? Link to comment https://forums.phpfreaks.com/topic/147752-solved-paragraph-parser/#findComment-775616 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 Link to comment https://forums.phpfreaks.com/topic/147752-solved-paragraph-parser/#findComment-775681 Share on other sites More sharing options...
cooldude832 Posted March 3, 2009 Share Posted March 3, 2009 unix vs windows break lines Link to comment https://forums.phpfreaks.com/topic/147752-solved-paragraph-parser/#findComment-775697 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.