All solutions above kind of work, until one starts to work with German language where there are such letters:
ä ä
and othere simial ones.
I use the following code:
$string = preg_replace ( "!\s++!u", ' ', $string );
More details here: PCRE(3) Library Functions Manual