rtrim() Function in PHP 8.1 and 8.2 With Example

Support PHP Version: PHP 7.1, PHP 7.2, PHP 7.3, PHP 7.4, PHP 8.0, PHP 8.1, PHP 8.2, PHP 8.3 With Latest All Version Support.

Hello Friends Today, through this tutorial, I will tell you How to Use `rtrim()` function using PHP, PHP 8, PHP 8.1, PHP 8.2 With Example. In PHP 8.1 and 8.2, the `rtrim()` function is used to remove whitespace or other specified characters from the end of a string. Here’s how you can use it with examples:

Syntax:

<?php
rtrim ( string $string , string $characters = " \t\n\r\0\x0B" ) : string
?>

Parameters:

1. `$string`: The input string to be trimmed.
2. `$characters` (optional): The characters you want to remove. If not provided, it will remove whitespace characters.

Return Value: Returns the trimmed string.

Example:

<?php

// Example 1: Removing whitespace from the end of a string
$string1 = "Hello World ";
$result1 = rtrim($string1);
echo "Result 1: '$result1'\n"; // Output: "Result 1: 'Hello World'"

// Example 2: Removing specific characters from the end of a string
$string2 = "Hello World!!!";
$result2 = rtrim($string2, "!");
echo "Result 2: '$result2'\n"; // Output: "Result 2: 'Hello World'"

// Example 3: Using with custom characters
$string3 = "Hello World123";
$result3 = rtrim($string3, "123");
echo "Result 3: '$result3'\n"; // Output: "Result 3: 'Hello World'"

?>

In these examples:

1. Example 1 demonstrates removing whitespace from the end of a string.
2. Example 2 shows removing exclamation marks from the end of a string.
3. Example 3 illustrates using `rtrim()` with custom characters to remove ‘1’, ‘2’, and ‘3’ from the end of the string.

These examples should give you a good understanding of how to use `rtrim()` in PHP 8.1 and 8.2.

Cialis (Tadalafil) är den främsta konkurrenten till Viagra (Sildenafil) på marknaden för erektil dysfunktion. köpa Cialis i Sverige föredras av många på grund av sin längre varaktighet och anses vara det mest kostnadseffektiva varumärkesbaserade ED-läkemedlet som finns tillgängligt i Sverige. Cialis finns i två varianter: Cialis och Cialis Daily, och fyra olika doseringar: 2,5 mg, 5 mg, 10 mg och 20 mg, erbjuder Cialis också en rad olika alternativ för att passa patientens behov.