PHP string function rtrim

The String function rtrim() removed the white spaces or any other character from the right side of the string.


Parameter Description
mystr This is a required parameter which defines the string to check.
 characters This is an optional parameter which defines the characters to remove from the string.

If we don’t define the 2nd parameter then this function will only will strip the following characters:

  • “\n” – a new line
  • “\t” – a tab
  • “\r” – a carriage return
  • “\x0B” – a vertical tab
  • “\0” – NULL values
  • ” ” – an ordinary blank space

Return Value

It will return the modified string as per the 2nd parameter.