mb_rtrim()

mb_rtrim() — Strip whitespace (or other characters) from the end of a string.

Built-in function of PHP 8.5. The manual lists it as available in PHP 8 >= 8.4.0. This page is the reference card: signature, parameters and return value, plus the changelog and the example the manual provides.

What it does

Performs a multi-byte safe rtrim() operation, and returns a string with whitespace (or other characters) stripped from the end of string.

Signature

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

Parameters

ParameterTypeWhat it takes
$stringstringThe input string.
$characters?stringOptionally, the stripped characters can also be specified using the characters parameter. Simply list all characters that need to be stripped.
$encoding?stringThe encoding parameter is the character encoding. If it is omitted or null, the internal character encoding value will be used.

Return value

Returns the modified string.

Example

The PHP manual ships no example for mb_rtrim(); the signature and the parameter table above are the contract.

See also

mb_trim(), mb_ltrim(), rtrim()

All PHP 8.5 built-in functions

Reference card built from the PHP manual page mb_rtrim() (PHP documentation, CC BY 3.0). The page is generated from the manual, so the wording of the parameter and return value text follows php.net.