Home  >  Article  >  Backend Development  >  How to use php rtrim function

How to use php rtrim function

藏色散人
藏色散人Original
2019-05-23 13:32:153860browse

php The rtrim() function is used to remove spaces or other predefined characters (if specified) on the right side of the string and return the modified string; the syntax is "rtrim(string,charlist)", parameter string Specify the string to be processed, and the parameter charlist specifies which characters to delete from the string.

How to use php rtrim function

How to use the rtrim() function?

Function: Remove spaces or other predefined characters on the right side of the string and return the modified string.

Syntax:

rtrim(string,charlist)

Parameters:

  • string, the string to be processed.

  • charlist Optional, specifies which characters to delete from the string, if empty, remove all the following characters "\0" -- NULL, "\t" -- Tab character, "\n" -- line feed, "\x0B" -- vertical tab character, "\r" -- carriage return, " " -- space

Return Value: Returns the modified string.

php rtrim() function usage example:

<?php
$i = "hello world    ";
echo "未经过处理的".$i."右边是有空格的!";
$j = rtrim($i);
echo "经过处理的".$j."右边是没有空格的!";
?>

Output:

未经过处理的hello world 右边是有空格的!经过处理的hello world右边是没有空格的!

The above is the detailed content of How to use php rtrim function. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:How to use php strrevNext article:How to use php strrev