The Little Guy Posted August 6, 2009 Share Posted August 6, 2009 In my database, I have these lines: This is line one! This is another line. echo '<p>'.preg_replace("~\n\n~m", '</p><p>', $row['about']).'</p>'; When the above code runs, it doesn't replace two new lines with: '</p><p>' that I tell it to. Why not? Link to comment https://forums.phpfreaks.com/topic/169162-solved-replacing-two-new-lines-with-paragraph-tags/ Share on other sites More sharing options...
nrg_alpha Posted August 7, 2009 Share Posted August 7, 2009 You might be able to use \R (which represents any line ending sequence): Example: $str = 'This is line one! This is another line.'; $str = preg_replace('#\R+#', '</p><p>', $str); Link to comment https://forums.phpfreaks.com/topic/169162-solved-replacing-two-new-lines-with-paragraph-tags/#findComment-892627 Share on other sites More sharing options...
The Little Guy Posted August 7, 2009 Author Share Posted August 7, 2009 Perfect son! Link to comment https://forums.phpfreaks.com/topic/169162-solved-replacing-two-new-lines-with-paragraph-tags/#findComment-892675 Share on other sites More sharing options...
nrg_alpha Posted August 7, 2009 Share Posted August 7, 2009 Wait, you're 23 and your calling me son? lol Link to comment https://forums.phpfreaks.com/topic/169162-solved-replacing-two-new-lines-with-paragraph-tags/#findComment-892955 Share on other sites More sharing options...
The Little Guy Posted August 9, 2009 Author Share Posted August 9, 2009 Just a figure of speech Thanks for the help though! Link to comment https://forums.phpfreaks.com/topic/169162-solved-replacing-two-new-lines-with-paragraph-tags/#findComment-893922 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.