glcummins helped me with this earlier -- I needed to loop through all $_POST variables in order to trim() and addslashes() -- but I also need to remove all double quotes. For some reason, adding preg_replace to this function doesn't work correctly. The function escapes double-quotes even though I've removed them with the preg_replace first.
$myVars = array();
foreach($_POST as $field=>$value)
$myVars[$field] = preg_replace('/\"/','',$myVars[$field]);
$myVars[$field] = trim(addslashes($value));
print $myVars[$field]; // to test