Removing more than one white-space
Try this:-
$desc = "hello what is my name";
echo trim(preg_replace('/\s+/', ' ', $desc));
Found the solution:
<?php
$str = ' This is a test ';
$count = 1;
while($count)
$str = str_replace(' ', ' ', $str, $count);
?>
This should do it:
$replaced = preg_replace('/\s\s+/', ' ', $text);
Output:
hello what is my name