PHP Tutorial





Español Français 中文 Deutsch Portuguese Japanese nederlands
   
 
PHP Topics
Introduction Introduction
Syntax Syntax
Data Types Data Types
Operators Operators
Control Structures Control Structures
Functions Functions
Pre-defined Function Pre-defined Function
Calendar Functions Calendar Functions
Date and Time Date and Time
Array Functions Array Functions
Array List Array Functions List1
Array Function List Array Functions List2
Math Functions Math Functions
PHP MYSQL Functions PHP Mysql Functions
File Handling File Handling
Error Handling Error Handling
DB Size DB Size
PHP Mail PHP Mail
String Tokens String Tokens
String Functions String Functions
String Functions List String Functions List1
String Functions List2 String Functions List2
Session Functions Session Functions
Cookies Functions Cookies Functions
Form Variables Form Variables
Running PHP from JS Running PHP from JS
Array To JS Array To JS
JS Array Array to PHP
Encryption Encryption
Common Header Common Header
Forums Ask Your Doubts
Scraps More about PHP
Feedback Feedback
 




PHP rtrim Function


Tutorials »Php »

Topic

What is rtrim Function and how it is used in string?



Explanation

The rtrim function is used to strip whitespaces or other characters from the end of a string in PHP.

Syntax:
    rtrim(string,charlist)

the above syntax "string" specifies the strings to be stripped, "charlist" specifies the charatcers to be stripped as the user can specify from the following characters "\0 -NULL", "\t - tab","\n - new line","\x0B - vertical tab", "\r - carriage return", " " - ordinary white space".

Example:
    <?php
    $str = "Hiox India!                     ";
    $str2 = "Web Our World";
    echo "With rtrim: " .rtrim($str);
    echo $str2;
    echo "<br>";
    echo "Without rtrim: " . $str;
    echo $str2;
    ?>
Result::
    With rtrim: Hiox India!Web Our World
    Without rtrim: Hiox India! Web Our World

In the above example the spaces on the right of "Hiox india" is stripped and the result is displayed, in the second statement the result is displayed with a space in between the strings.






A Note

Learn PHP programming language tutorial with simple and neat example. Hope you enjoy this free tutorial. Do give us your valuable feedback and suggestions on this online tutorial. This is a Copyright Content.

Other Links

web hosting