Codice PHP:
<?php
$str 
"ciao     Giovanni";
echo 
preg_replace("/[ ]+/"" "$str);
?>