Remove the last character from string [duplicate]

Possible Duplicate:
PHP - Remove last character if it’s a period?

Which is fastest way to remove last character from string?

I have a string like


I would like to remove last ‘,’ and get the remaining string back

OUTPUT: a,b,c,d,e

What the fastest way to do this?


First I try without space rtrim($arraynama,","); and get error result.

Then I add a space and get good result: $newarraynama=rtrim($arraynama,", ");