小白教程
所有教程
关于
Search
172.70.130.72
172.70.130.72
参数设置
贡献
退出
操作
编辑
移动
保护
信息
历史
删除
查看“Func string chop”的源代码
本页内容
上一节:
Func_string_bin2hex
下一节:
Func_string_chr
因为以下原因,您没有权限编辑本页:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
{{DISPLAYTITLE:chop()}}[[分类:PHP字符串函数参考手册|4]] = PHP chop() 函数 = [[:分类:PHP字符串函数参考手册]] 移除字符串右侧的字符: <sample title="" desc="" lang="php" hererun="1"> <?php $str = "Hello World!"; echo $str . "<br>"; echo chop($str,"World!"); ?> </sample> == 定义和用法 == chop() 函数移除字符串右侧的空白字符或其他预定义字符。 == 语法 == <pre> chop(string,charlist) </pre> {| class="table table-striped table-hover" !width="50%"| 参数 !width="50%"| 描述 |- | string | 必需。规定要检查的字符串。 |- | charlist | 可选。规定从字符串中删除哪些字符。 如果 charlist 参数为空,则移除下列字符: * "\0" - NULL * "\t" - 制表符 * "\n" - 换行 * "\x0B" - 垂直制表符 * "\r" - 回车 * " " - 空格 |} == 技术细节 == {| class="table table-striped table-hover" | 返回值: | 返回已修改的字符串。 |- | PHP 版本: | 4+ |- | 更新日志: | 在 PHP 4.1.0 中,新增了 charlist 参数。 |} == 更多实例 == == 实例 1 == 移除字符串右侧的换行符(\n): <sample title="" desc="" lang="php" hererun="1"> <?php $str = "Hello World!\n\n"; echo $str; echo chop($str); ?> </sample> 上面代码的 HTML 输出如下(查看源代码): <sample title="" desc="" lang="php" hererun="1"> <!DOCTYPE html> <html> <body> Hello World! Hello World! </body> </html> </sample> 上面代码的浏览器输出如下: <sample title="" desc="" lang="php" hererun="1"> Hello World! Hello World! </sample> [[:分类:PHP字符串函数参考手册]]
返回至“
Func string chop
”。
上一节:
Func_string_bin2hex
下一节:
Func_string_chr