Home >Backend Development >PHP Tutorial >What does php chop function mean?

What does php chop function mean?

藏色散人
藏色散人Original
2019-05-23 13:36:262718browse

php The chop function is an alias of the rtrim function, which means to delete the spaces or other predefined characters on the right side of the string and return the modified string; the syntax is chop(string,charlist), and the string parameter specifies the processing The string, the charlist parameter specifies which characters to remove from the string.

What does php chop function mean?

What does the chop() function mean?

Function: The chop function is an alias of the rtrim function. Its function is the same as the rtrim function. It deletes spaces or other predefined characters on the right side of the string.

Syntax:

chop(string,charlist)

Parameters:

string, the string to be processed.

charlist Optional, specifies which characters to delete from the string. If it is empty, all the following characters will be removed. "\0" -- NULL, "\t" -- Tab character, "\ n" -- line feed, "\x0B" -- vertical tab, "\r" -- carriage return, " " -- space.

Description: Return the string processed by charlist rules.

php chop() function usage example

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

Output:

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

The above is the detailed content of What does php chop function mean?. 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

Related articles

See more