ifis Posted February 9, 2008 Share Posted February 9, 2008 I am trying to set up a simple blog. I have a textarea where people can input their thoughts, but when I process the input through the programming it all of the spacing, most importantly the paragraph spacing is removed. I want to be able to find areas in the text where there are multiple spaces and then replace those with a </p><p>. $correctarticle=preg_replace(' ++',</p><p>,$_POST['Article']); this is not working. Any ideas? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/90178-solved-getting-proper-spacing-in-a-text-field-using-preg_replace/ Share on other sites More sharing options...
trq Posted February 9, 2008 Share Posted February 9, 2008 Check out nl2br and if need be the user notes. Quote Link to comment https://forums.phpfreaks.com/topic/90178-solved-getting-proper-spacing-in-a-text-field-using-preg_replace/#findComment-462411 Share on other sites More sharing options...
ifis Posted February 9, 2008 Author Share Posted February 9, 2008 taking a look at it now. thanks Quote Link to comment https://forums.phpfreaks.com/topic/90178-solved-getting-proper-spacing-in-a-text-field-using-preg_replace/#findComment-462417 Share on other sites More sharing options...
ifis Posted February 9, 2008 Author Share Posted February 9, 2008 I'm still trying to figure out how to implement it. I tried 2 different ways and it is not working. Here is what I tried. $Article=(remove_headers($_POST['Article'])); $Article= nl2br($Article); echo "$article"; and article=$_POST['Article']; echo nl2br("$article"); any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/90178-solved-getting-proper-spacing-in-a-text-field-using-preg_replace/#findComment-462426 Share on other sites More sharing options...
ifis Posted February 9, 2008 Author Share Posted February 9, 2008 oops, just noticed, I need a 'A' instead of 'a'. sorry Quote Link to comment https://forums.phpfreaks.com/topic/90178-solved-getting-proper-spacing-in-a-text-field-using-preg_replace/#findComment-462430 Share on other sites More sharing options...
ifis Posted February 9, 2008 Author Share Posted February 9, 2008 It worked perfect. The help is much appreciated! Quote Link to comment https://forums.phpfreaks.com/topic/90178-solved-getting-proper-spacing-in-a-text-field-using-preg_replace/#findComment-462431 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.