note 52870 deleted from function.nl2br by googleguy

From: Date: Thu, 13 Jun 2013 11:07:29 +0000
Subject: note 52870 deleted from function.nl2br by googleguy
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-195161@lists.php.net to get a copy of this message
Note Submitter: kristen at paristemi dot com ---- A note to add to the br2nl. Since nl2br doesn't remove the line breaks when adding in the <br /> tags, it is necessary to strip those off before you convert all of the tags, otherwise you will get double spacing. Here is the modified function: function br2nl($str) { $str = preg_replace("/(\r\n|\n|\r)/", "", $str); return preg_replace("=<br */?>=i", "\n", $str); }

« previous php.notes (#195161) next »