note 82898 modified in function.nl2br by thiago

From: Date: Thu, 05 Mar 2009 12:16:01 +0000
Subject: note 82898 modified in function.nl2br by thiago
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-151517@lists.php.net to get a copy of this message
function to replace all \n\n\n\n\n\n \r\r\r\r only one <br /> <?php function Only1br($string) { return preg_replace("/(\r\n)+|(\n|\r)+/", "<br />", $string); } $string = "this is \n\n\n a String with many \n\n\r\r returns!"; $string = Only1br($string); //returns: this is <br /> a String with many <br /> returns!"; ?> --was-- function to replace all \n\n\n\n\n\n \r\r\r\r only one <br /> function Only1br($string) { return preg_replace("/(\r\n)+|(\n|\r)+/", "<br />", $string); } $string = "this is \n\n\n a String with many \n\n\r\r returns!"; $string = Only1br($string); //returns: this is <br /> a String with many <br /> returns!"; http://php.net/manual/en/function.nl2br.php

« previous php.notes (#151517) next »