Re: [PHP-DEV] Function proposal: nl2p

2004-03-07 Thread Sara Golemon
> Intresting for users that need such functions on several places in code
and in
> this case better as regexp in PHP itself. Why not take this ideas and put
> together into ext/html(format)?
>
I agree with the statement that functions like these (and nl2br() itself)
don't really belong in the PHP core, but if you feel passionate about them,
you're more than welcome to create an htmlformat extension in PEAR or PECL.

-Sara

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] Function proposal: nl2p

2004-03-07 Thread Kai Schröder
On Sunday 07 March 2004 21:58, Stefan Walk wrote:
> 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  tag does not have as much possibilities as the  tag when
> > it comes to CSS, which gave me the idea to write this function.
> function nl2p($str) {
>   return ''.preg_replace('/\r\n|\n|\r/', '$0', $str).'';
> }
> 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.

More ideas for intresting functions specialy for websites:
- nl2span($text,  $array_of_arguments_for_span)
- nl2div($text,  $array_of_arguments_for_div)
- obfuscate_mailaddr($mail_addr).

Intresting for users that need such functions on several places in code and in 
this case better as regexp in PHP itself. Why not take this ideas and put 
together into ext/html(format)?

Regards, Kai

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] Function proposal: nl2p

2004-03-07 Thread Stefan Walk
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  tag does not have as much possibilities as the  tag when 
> it comes to CSS, which gave me the idea to write this function.
> 
> --

function nl2p($str) {
  return ''.preg_replace('/\r\n|\n|\r/', '$0', $str).'';
}

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
<[EMAIL PROTECTED]>

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] Function proposal: nl2p

2004-03-07 Thread Markus Fischer
On Sun, Mar 07, 2004 at 01:07:08PM -0500, Louis-Philippe Huberdeau wrote : 
> /* {{{ proto string nl2p(string str)
>Converts newlines to HTML paragraphs for standard compliance */

I'm not to judge whether this goes in or not, however using
paragraphs is not more standard compliance than breaks. Breaks
aren't deprecated in the current version of HTML.

It's about semantics, not about standard compliance. This should be
called by the right name if it's used.

- Markus

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php