[Webdev] Links in a form.

Raf turiel at Redbrick.DCU.ie
Mon Sep 11 17:01:53 IST 2000


On Mon, 11 Sep 2000, adam beecher wrote:

> > $details = ereg_replace(10,  "<BR>", $details);
> > $details = ereg_replace(13,  "", $details);
> >
> > And that will add a <br> to all the $details when it comes across a
> > linefeed.
> >
> Ummm, wha about nl2br()? Actually, nl2br() is imperfect - it screws up layouts
> because it doesn't really replace newlines, it just adds in a <BR> tag. If you
> .....

I asked this question on phpbuilder.com before and got the following
response:

----
nl2br() is probably not the best way to do it.

The following will replace blank lines with <P> and allow the the rest of the
copy to "flow" naturally.

$message = ereg_replace("\r\n\r\n", "\n<P>", $message);
----

It worked fine for me (in a message board application).






More information about the Webdev mailing list