PHP

PHP Menu

PHP

rtrim() Function - Definition, Syntax, Parameters, Examples

Definition

The rtrim() function removes whitespace or other predefined characters from the right side of a string.

Syntax

rtrim(string, charlist)

Parameters

Parameter Description
string Required. Specifies the string to check.
charlist Optional. Specifies which characters to remove from the string. If omitted, all of the following characters are removed:
"\0" - null
"\t" - tab
"\n" - new line
"\x0B" - vertical tab
"\r" - carriage return
" " - ordinary white space

Example

<?php
$hello = "Hello World! "; echo "Without rtrim: " . $hello; echo "<br>"; echo "With rtrim: " . rtrim($hello);

Introduction

PHP Basics

PHP Advance

PHP OOP

PHP Functions and Methods