note 66261 added to function.nl2br

From: Date: Thu, 18 May 2006 04:12:56 +0000
Subject: note 66261 added to function.nl2br
Groups: php.notes 
Request: Send a blank email to php-notes+get-111538@lists.php.net to get a copy of this message
I have modified my function found in the previous post. It now uses preg_replace() which should technically be faster than ereg_replace(). You can also specify what you want to replace "\r\n" with. If you use the function with only one parameter, it will use '<br />' by default. <?php function nl2brStrict($text, $replacement = '<br />') { return preg_replace("((\r\n)+)", trim($replacement), $text); } ?> ---- Server IP: 216.235.15.211 Probable Submitter: 24.37.25.43 ---- X-Spam-Status: No, hits=3.3 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER, HTML_MESSAGE autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/function.nl2br.php Edit -- http://master.php.net/note/edit/66261 Del: integrated -- http://master.php.net/note/delete/66261/integrated Del: useless -- http://master.php.net/note/delete/66261/useless Del: bad code -- http://master.php.net/note/delete/66261/bad+code Del: spam -- http://master.php.net/note/delete/66261/spam Del: non-english -- http://master.php.net/note/delete/66261/non-english Del: in docs -- http://master.php.net/note/delete/66261/in+docs Del: other reasons-- http://master.php.net/note/delete/66261 Reject -- http://master.php.net/note/reject/66261 Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#111538) next »