Remove any doubled-up whitespace
<?php $str = " This line contains\tliberal \r\n use of whitespace.\n\n"; $str = preg_replace('/\s(?=\s)/', '', $str); // Echo out: 'This line contains liberal use of whitespace.' echo "<pre>{$str}</pre>"; ?>