trim() is just for whitespace. You need to use the ereg() functions, for example:
// From the beginning
$string = ereg_replace(\",\", \"\", $string);
// From the end
$string = ereg_replace(\",$\", \"\", $string);
If you have whitespace as well, you\'ll need to run trim() first.
RTFM & HTH,
adam