Best way I have is with regular expressions.
$string = ",blah,blah,blah";
$string = ereg_replace("(,|,$)", "", $string);
Now, the first comma is cut of. It would cut off the last comma if there was one there as well. Basically all the regular expression says is this:
(,|,$)
take out the parentheses and we have
,|,$
The pipe symbol (|) just means "or". So we have
, OR ,$
The ^ means match the beginning of the string given to us, and the $ means match the end of the string for us. So...
(Beginning of string), OR ,(End of String)
With ereg_replace, we match either one of those and give it a second argument to replace it with, in this case, "" nothing. And the third argument is, of course, the string we are matching against. Hope that helps!
Chris King