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? Quote 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); Quote 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! Quote 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 Quote 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! Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.