Re: Function proposal: nl2p
| From: | Stefan Walk | Date: | Sun, 07 Mar 2004 20:58:31 +0000 |
| Subject: | Re: Function proposal: nl2p | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-8423@lists.php.net to get a copy of this message | ||
On Sun, Mar 07, 2004 at 01:07:08PM -0500, Louis-Philippe Huberdeau wrote:
> I wrote this very simple function (modification from nl2br actually) to
> convert newlines to well formatted HTML paragraphs instead of line
> breaks, allowing better formatting of a dynamic output. It's not the
> most perfect piece of code ever written, but it works and it can be
> quite useful.
>
> The <br /> tag does not have as much possibilities as the <p> tag when
> it comes to CSS, which gave me the idea to write this function.
>
> --
function nl2p($str) {
return '<p>'.preg_replace('/\r\n|\n|\r/',
'</p>$0<p>', $str).'</p>';
}
I think that function is not neccessary... nl2br is already redundant.
They are one-liners in php itself... so no need to write functions for
them.
--
Regards,
Stefan Walk
<swalk@prp.physik.tu-darmstadt.de>