]*?>(.|\n)*?<\/".$tag.">/", $string, $pre1);
for ($x = 0; $x < count($pre1[0]); $x++) {
$pre2[$x] = preg_replace("/\s*
]*?>\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*
]*?>\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*
]*?>\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)));
}
?>