PHP Replace Any Non-Space Whitespace, With Space – String Function

<?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}

“;
?>

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.