note 8072 added to nl2br

From: Date: Sat, 26 Aug 2000 00:35:49 +0000
Subject: note 8072 added to nl2br
Groups: php.notes 
Request: Send a blank email to php-notes+get-3269@lists.php.net to get a copy of this message
This function replaces \n's with BR's unless a BR is already on that line. function replace_nl($string) { // cut the value up by \n's $lines = explode (" ", $string); $index=0; while($lines[$index]) { $lines[$index] = trim($lines[$index]); if(substr($lines[$index], strlen($lines[$index]) - 4, 4) != "<br>") $lines[$index] .= "<br>"; $return_result .= $lines[$index]; $index++; } return $return_result; } http://www.php.net/manual/function.nl2br.php

« previous php.notes (#3269) next »