remove any commas at the end of a string php code example Example: php remove last character from string if comma $string = rtrim($string, ',');