#php: Replace all multiple newlines with one. multiple space
function wrap_text($string = "") {
//Replace all multiple new lines with one
$string = preg_replace('"(\r?\n){2,}"', "\n\n", $string);
//Replace multiple spaces, tabs with single space
$string = preg_replace('"/(\t| ){2,}/"', "$1", $string);
return $string;
}
Comments