PHP chop() 函数

2024 年 9 月 4 日 | 阅读 1 分钟

chop() 函数用于从字符串的右侧移除空格或其他预定义的字符。

语法

注意:chop() 函数与 Perl 的 chop() 函数不同,Perl 的 chop() 函数用于移除字符串的最后一个字符。

参数描述必需/可选
string要检查的字符串必需
字符列表charlist 参数为空可选

示例 1

输出

Your string is :Hello World!
By using 'chop()' Functions is your string is: Hello

示例 2

输出

Your string is :Hello World!
By using 'chop()' Functions is your string is: Hello World!

示例 3

输出

Your string is :Hello World! 
By using 'chop()' Functions is your string is: Hello World!

下一主题PHP 字符串