<?php $str = " This line contains\tliberal \r\n use of whitespace.\n\n"; $str = preg_replace('/[\n\r\t]/', ' ', $str); // Echo out: 'This line contains liberal use of whitespace.' echo "<pre>{$str}</pre>"; ?>