PHP rtrim function
The PHP rtrim function can be used to delete the blank characters at the end of the string. In addition, PHP 4.1.0 version adds the function of the $charlist parameter, so that the rtrim function can also be removed by setting the parameter $charlist For other characters (characters), the function corresponding to rtrim is the ltrim function, which is used to clear the blank characters at the beginning of the string. If you want to clear other characters other than the ending blank, you can refer to " PHP Remove Strings "Last Character ", let’s take a look at the syntax and examples of the PHP rtrim function in this topic.
Basic syntax of PHP rtrim function
PHP rtrim function example
$text_str = "Welcome to Jason SEO ";
$new_str_1 = rtrim($text_str);
var_dump($new_str_1);
echo'<br>';
$new_str_2 = rtrim($text_str,'.');
var_dump( $new_str_2);
?>
string(17) "Welcome to Jason SEO"
The rtrim function is very useful in dealing with general whitespace, but if you encounter full-width whitespace characters, the default mode of the rtrim function cannot remove the full-width whitespace, but it does not matter. You can use the second method in the example. That is, the full-width blank is treated as a special character and can be removed with the technique of the $charlist parameter.
Post a Comment
0 Comments