Wanted to convert
into
You probably want to use a Regular Expression. I haven't tested the following, but I believe it's right.
$text = preg_replace( "/()+/i","", $text );