Home » PHP rtrim() function

PHP rtrim() function

by Online Tutorials Library

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:

Parameter Description Required/Optional
string Specify the string to check. required
charlist Specify character to remove Following character

  • “” – 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

You may also like