rtrim() function in php
0 2869
PHP rtrim() function is used to remove the user-defined text or whitespaces from the right side of a string. It is an inbuilt function in PHP. The return type of this function is a string.
NOTE:
- If you want to remove some user-defined text or white space from the left side of any string, use ltrim() PHP function.
- If you want to remove some user-defined text or white space from both sides of any string, use trim() PHP function.
Syntax:
rtrim($string,$characters);
here,
- $string is a PHP string from which we want to remove either some predefined texts or white space used by this function. It is mandatory.
- $characters are predefined text which we want to remove from the given string. It is optional.
Example:
<?php $string="Hello everyone !!! welcome to our site"; $mod_string=rtrim($string,"welcome to our site"); echo "Original string is : <strong>$string</strong><br>"; echo "Modified string is : <strong>$mod_string</strong>"; ?>
Output:
Share:
Comments
Waiting for your comments