[thelist] ereg_replace \n having some probs

Chris W. Parker cparker at swatgear.com
Wed Jan 22 11:39:01 CST 2003

Dunstan Orchard <mailto:dunstan at 1976design.com> wrote:

> But what I'd like to do is allow people to decide if they want a new
> line or a new paragraph:
> $news = $row["news"];
> $news = stripslashes($news);
>  // if they've pressed return twice, then put in paragraph tags
>  $news = ereg_replace("\n\n","</p>\r\n<p>",$news);

do you also take into account that you would need to prepend a <p> tag
if this situation occurs? otherwise you'll have an ending </p> and a
beginning <p>, but not for the same paragraph. this of course wouldn't
count if the whole text by default was wrapped in <p></p>. but since i
don't know exactly what you are doing, i'll just assume you are not
doing that.

>  // if they pressed return once, put in line break
>  $news = ereg_replace("\n","<br />\r\n",$news);

hmm... i was thinking that because you have two statements in a row that
that could be a part of the reason you're getting strange results. but
then again if that was the case you should still see the </p><p> tags,
but with a <br /> in between them. so i don't think that's what is

what do you get if you try something like...

$news = ereg_replace("\n","x",$news);

would you get two x's or would you just get one x?


More information about the thelist mailing list