PHP string rtrim() Function

PHP rtrim() is predefined function which is used to remove whitespace or character form the right side of a string.

Syntax:

ParameterDescriptionRequired/Optional
stringSpecify the string to check.required
charlistSpecify character to remove Following character
  • "\0" - NULL
  • "\t" - tab
  • "\n" - new line
  • "\x0B" - vertical tab
  • "\r" - carriage return
  • " " - ordinary white space
Optional

Example 1

Output:

Without rtrim() function: Hello PHP! 
With rtrim() function:Hello PHP!

Example 2

Output:

Without trim() function: Hello PHP! 
With trim() function: Hello PHP!

Next TopicPHP String




Latest Courses