note 65953 added to function.nl2br

From: Date: Wed, 10 May 2006 18:10:33 +0000
Subject: note 65953 added to function.nl2br
Groups: php.notes 
Request: Send a blank email to php-notes+get-111080@lists.php.net to get a copy of this message
I wanted to replace all new lines with a *single* <br /> so that users couldn't do multiple new lines and make pages look ugly. Here is the function, just use nl2brStrict($yourText) instead of nl2br($yourText) : <?php function nl2brStrict($text) { return ereg_replace("(\r\n)+", '<br />', $text); } ?> ---- Server IP: 66.207.199.35 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/65953 Del: integrated -- http://master.php.net/note/delete/65953/integrated Del: useless -- http://master.php.net/note/delete/65953/useless Del: bad code -- http://master.php.net/note/delete/65953/bad+code Del: spam -- http://master.php.net/note/delete/65953/spam Del: non-english -- http://master.php.net/note/delete/65953/non-english Del: in docs -- http://master.php.net/note/delete/65953/in+docs Del: other reasons-- http://master.php.net/note/delete/65953 Reject -- http://master.php.net/note/reject/65953 Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#111080) next »