PHP rtrim() Function
In this chapter you will learn:
- Definition for PHP rtrim() Function
- Syntax for PHP rtrim() Function
- Parameter for PHP rtrim() Function
- Return for PHP rtrim() Function
- Example - trim a string from right
Definition
The rtrim()
function trims whitespace from the righthand side of a string.
Syntax
PHP rtrim() Function has the following syntax.
string rtrim ( string str [, string trim_chars] )
Parameter
The optional second parameter to trim() sets the individual characters you want it to trim.
Return
PHP rtrim() Function returns the right trimmed string.
Example
trim a string from right
<?PHP
$string = rtrim(" java2s.com ");
print ">"+$string+"<";
?>
The code above generates the following result.
Next chapter...
What you will learn in the next chapter:
- Definition for PHP setlocale() Function
- Syntax for PHP setlocale() Function
- Parameter for PHP setlocale() Function
- Locale information
- Return for PHP setlocale() Function
- Example - Set the locale to US English and then back to default again
Home » PHP Tutorial » PHP String Functions