note 52870 added to function.nl2br

From: Date: Mon, 16 May 2005 08:12:44 +0000
Subject: note 52870 added to function.nl2br
Groups: php.notes 
Request: Send a blank email to php-notes+get-89479@lists.php.net to get a copy of this message
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); } ---- Manual Page -- http://www.php.net/manual/en/function.nl2br.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+52870 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+52870&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+52870&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+52870&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+52870&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+52870&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+52870&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#89479) next »