HomeMenu
Jesus · Bible · HTML · CSS · JS · PHP · SVG · Applications

mb_rtrim

Description

The mb_rtrim of Multibyte String for PHP strips whitespace (or other characters) from the end of a string.

Syntax

mb_rtrim(
    string $string,
    ?string $characters = null,
    ?string $encoding = null
): string

Parameters

string

The input string.

characters

The list of all the characters that need to be stripped.

encoding

The character encoding.

If omitted or null, the internal character encoding value will be used.

Return

Returns a string with whitespace stripped from the end of the string.

Examples

1 · string

<?

$string = "🐘string\0\t\n\v\r \x00\x09\x0A\x0B\x0D\x20";

$return = mb_rtrim($string);

var_dump($string, $return);
string(22) "🐘string    

     

 "
string(10) "🐘string"

2 · characters

<?

$string = "🐘string\0\t\n\v\r \x00\x09\x0A\x0B\x0D\x20";
$characters = "\0\t\n\v\r ng";

$return = mb_rtrim($string, $characters);

var_dump($string, $return);
string(22) "🐘string    

     

 "
string(8) "🐘stri"

3 · encoding

<?

$string = "🐘string\0\t\n\v\r \x00\x09\x0A\x0B\x0D\x20";
$characters = "\0\t\n\v\r ng";
$encoding = "UTF-8";

$return = mb_rtrim($string, $characters, $encoding);

var_dump($string, $return);
string(22) "🐘string    

     

 "
string(8) "🐘stri"