Home > PHP > Compress output

Compress output

January 18, 2010

Remove new lines && multiple consecutive whitespaces from content


/**
 * Remove new lines && multiple consecutive whitespaces from content
 */
function compress( $content )
{
	$content = trim(ereg_replace("\n|\r|\r\n|\n\r", '', preg_replace('/\s+/', ' ', $content)));
	return $content;
}
Advertisements
%d bloggers like this: