The chop function removes whitespace from the end of a string. It is an alias of the function rtrim.
chop
rtrim
chop(string $string, string $characters = " \t\n\r\0\x0B"): string