How to use php rtrim function

藏色散人
Release: 2023-04-06 19:00:02
Original
3871 people have browsed it

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)
Copy after login

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."右边是没有空格的!";
?>
Copy after login

Output:

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

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template