Hi,
I know:
str_replace(" ","",$variable)
will strip space charachters BUT...
How can large amounts of whitespace be stripped to leave one space.
e.g.
" "
to
Doe's any one know a method?
One way to do it:
while (strpos($variable, ' ') !== false) { $variable = str_replace(' ', ' ', $variable); }
Well, this sorta works:
<?php $datatata = 'Helooo e reoeo grjgjrj n mmmgm'; $a = preg_replace ( "/\s+/", ' ', $datatata ); echo '<pre>' . print_r($a,true) . '</pre>'; ?>
BUT it also replaces new lines with just a space. So make sure to put your <br>'s in beforehand.