Posts Tagged ‘php function nl2p nl2br’

PHP nl2p Function

Sunday, August 3rd, 2008

Forget nl2br! With this nl2p function your content will be better formatted and code better presented.

1
2
3
4
5
6
7
function nl2p($string)
{
	$string = "<p>" . $string . "</p>";
	$string = preg_replace("/\r\n\r\n/", "</p>\n\n<p>", $string);
	$string = preg_replace("/\r\n/", "<br />", $string);
	return $string;
}