Edit report at https://bugs.php.net/bug.php?id=64639&edit=1

 ID:                 64639
 Comment by:         ni...@php.net
 Reported by:        valentiny510 at yahoo dot es
 Summary:            Add third parameter to nl2br
 Status:             Open
 Type:               Feature/Change Request
 Package:            *General Issues
 PHP Version:        Irrelevant
 Block user comment: N
 Private report:     N

 New Comment:

In my eyes this is an unnecessary change. nl2br handles the common case, where 
you want to have linebreaks displayed and have the code nicely formatted at the 
same time. This is what nl2br does and I don't think it need to do any more.

I don't see why we should add support for incorrect usages of the function 
inside <pre>. And in any case, if you should have need for this (for whatever 
odd reason), then it is trivial to write yourself. Quite honestly I think that 
preg_replace('#([\r?\n]+)#', '<br>', $string) is a good bit clearer than 
nl2br($string, false, true). That's just too many unclear boolean parameters.


Previous Comments:
------------------------------------------------------------------------
[2013-05-03 07:01:13] octavianmarinescu at tavi dot ro

yes would be a shorter and more elegant solution

    nl2br($str, false, true);

nice and clean..

------------------------------------------------------------------------
[2013-04-17 19:44:35] krak...@php.net

The following patch has been added/updated:

Patch Name: nl2br_additional_parameter
Revision:   1366227875
URL:        
https://bugs.php.net/patch-display.php?bug=64639&patch=nl2br_additional_parameter&revision=1366227875

------------------------------------------------------------------------
[2013-04-12 02:12:27] valentiny510 at yahoo dot es

Description:
------------
The name "nl2br" for somebody who doesn't know php very well, suggest that 
actually replace "nl" with "br" but is not true. The name of the function 
function should be "nl2nl+br"

I think it should have a third parameter like $replace, and actually Replace 
the nl with br

I have some clients who used this function inside pre with horrible result.
Anyway, I think it will be more usefull this

nl2br ($string, true/false, $replace = true/false)

than

preg_replace('#([\r?\n]+)#', '<br>', $string) or
str_replace(array("\r\n", "\r", "\n"), '<br>', $string)




------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=64639&edit=1

Reply via email to