I'm trying to clean up a string (get rid of special characters, but preserve spaces, and remove trailing spaces) My solution (below) works, but I have a feeling it could be done more elegantly. Suggestions would be greatly appreciated.
function clean($input) {
$output = ereg_replace("['\"!@#$%&/()_=`-]{1,9} ", " ", $input);
$output = ereg_replace(" +", " ", $output);
$output = ereg_replace(" $", "", $output);
return $output;
}