All pastes #108378 Raw Edit

Smith

public php v1 · immutable
#108378 ·published 2006-07-31 13:35 UTC
rendered paste body
<?phpfunction nl2br_nopre($string, $wrap = 40) {	$tag = 'pre';		preg_match_all("/<".$tag."[^>]*?>(.|\n)*?<\/".$tag.">/", $string, $pre1);		for ($x = 0; $x < count($pre1[0]); $x++) {		$pre2[$x] = preg_replace("/\s*<br[^>]*?>\s*/", "", $pre1[0][$x]);		$pre2[$x] = preg_replace("/([^\n]{".$wrap."})(?!<\/".$tag.">)(?!\n)/", "$1\n", $pre2[$x]);		$pre1[0][$x] = "/".preg_quote($pre1[0][$x], "/")."/";	}		$string = preg_replace($pre1[0], $pre2, $string);			return $string;}function nl2br_notable($string, $wrap = 40) {		$tag = 'table';		preg_match_all("/<".$tag."[^>]*?>(.|\n)*?<\/".$tag.">/", $string, $pre1);		for ($x = 0; $x < count($pre1[0]); $x++) {		$pre2[$x] = preg_replace("/\s*<br[^>]*?>\s*/", "", $pre1[0][$x]);		$pre2[$x] = preg_replace("/([^\n]{".$wrap."})(?!<\/".$tag.">)(?!\n)/", "$1\n", $pre2[$x]);		$pre1[0][$x] = "/".preg_quote($pre1[0][$x], "/")."/";	}		$string = preg_replace($pre1[0], $pre2, $string);			return $string;}function nl2br_noul($string, $wrap = 40) {		$string = nl2br($string);		$tag = 'ul';		preg_match_all("/<".$tag."[^>]*?>(.|\n)*?<\/".$tag.">/", $string, $pre1);		for ($x = 0; $x < count($pre1[0]); $x++) {		$pre2[$x] = preg_replace("/\s*<br[^>]*?>\s*/", "", $pre1[0][$x]);		$pre2[$x] = preg_replace("/([^\n]{".$wrap."})(?!<\/".$tag.">)(?!\n)/", "$1\n", $pre2[$x]);		$pre1[0][$x] = "/".preg_quote($pre1[0][$x], "/")."/";	}		$string = preg_replace($pre1[0], $pre2, $string);			return $string;}function enter2br($string) {	return nl2br_nopre(nl2br_notable(nl2br_noul($string)));}?>