PHP rtrim() Function

PHP quotemeta() Function
PHP setlocale() Function

what is the syntax of the RTRIM() function in php?

rtrim(string,charlist)
ParameterDescription
stringRequired. Specifies the string to check
charlistOptional. 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
PHP RTRIM() method

examples of the RTRIM() function

Examples 1. In this example, we remove characters from the right side of a string.

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

Examples 2. In this example, we remove whitespaces from the right side of a string.

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

Examples 3. In this example, we remove newlines (\n) from the right side of a string.

<?php
$str = "Hello World!\n\n\n";
echo "Without rtrim: " . $str;
echo "<br>";
echo "With rtrim: " . rtrim($str);
?>
PHP quotemeta() Function
PHP setlocale() Function
en English
X
Scroll to Top