How do you remove whitespaces from a string in PHP?

Answer:
<?php
trim(ereg_replace( ' +', ' ', $extraWhiteSpace));
?>
First answer by Katierosy. Last edit by Katierosy. Contributor trust: 3 Question popularity: 1 [recommend question].