Req #64639 [Csd->Wfx]: Add third parameter to nl2br

From: Date: Sun, 04 Jan 2015 22:30:25 +0000
Subject: Req #64639 [Csd->Wfx]: Add third parameter to nl2br
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-189650@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=64639&edit=1 ID: 64639 Updated by: nikic@php.net Reported by: valentiny510 at yahoo dot es Summary: Add third parameter to nl2br -Status: Closed +Status: Wont fix Type: Feature/Change Request Package: *General Issues PHP Version: Irrelevant Assigned To: ajf Block user comment: N Private report: N Previous Comments: ------------------------------------------------------------------------ [2015-01-04 20:30:28] ajf@php.net For the reason stated before, I'm closing this. There's little worth in adding this, nor is it likely to ever happen. ------------------------------------------------------------------------ [2015-01-04 20:26:43] ajf@php.net Like Nikita, I don't see the point here. Within a <pre> you don't need to use nl2br(). Outside of a <pre>, you need to use nl2br(). Either way, the new-lines will be kept and your source code will be readable. The only argument for this would be efficiency. But it's not a massive saving, it's 20% off... but only for line endings. ------------------------------------------------------------------------ [2014-03-06 12:30:15] narf at devilix dot net The bigger issue here is how you'd reverse the process. Without knowing that the function just adds instead of replacing, one would try the following: function br2nl($string, $is_xhtml = TRUE) { return str_replace( $is_xhtml ? '<br />' : '<br>', PHP_EOL ); } The problem is that this would result in doubling the newline characters. ------------------------------------------------------------------------ [2013-07-13 01:42:30] valentiny510 at yahoo dot es As additional note.. If I can have linebreaks and nicely formated text in just one function, why don't do'it ? I don't think is such a big deal, or should change the name to something like "addbr2nl", it will be more "correct".. ------------------------------------------------------------------------ [2013-07-13 01:33:11] valentiny510 at yahoo dot es Nikic, 2 booleans parameters for you are "too many unclear boolean parameters" LOL... ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at https://bugs.php.net/bug.php?id=64639 -- Edit this bug report at https://bugs.php.net/bug.php?id=64639&edit=1

« previous php.bugs (#189650) next »