1、使用substr或mb_substr删除字符串最后一个字符
$string = \"This is test string..\";
echo $string . \"\\n\";
// substr function http://www.manongjc.com
echo \"substr: \" . substr($string, 0, -1);
echo \"\\n\";
// mb_substr multibyte version
echo \"mb_substr: \" . mb_substr($string, 0, -1);
echo \"\\n\";
输出结果:
This is test string..
This is test string.
This is test string.
2、使用substr_replace删除字符串最后一个字符
$string = \"This is test string..\";
echo $string . \"\\n\";
// substr_replace function
echo \"substr_replace: \" . substr_replace($string ,\"\",-1);
echo \"\\n\";
输出结果:
This is test string..
This is test string. 继续阅读与本文标签相同的文章
上一篇 :
php删除字符串末尾指定字符
-
全球首条“5G自动微公交”示范线路乌镇开通
2026-05-14栏目: 教程
-
未来十年,最为吃香的4个大学专业,毕业后就是香饽饽!
2026-05-14栏目: 教程
-
还不会制作填充地图,试试这种方法,2分钟搞定,让你秒变大神
2026-05-14栏目: 教程
-
顺丰自研机器人惊艳亮相,化身“快递小哥”亮绝活,盯上万亿市场
2026-05-14栏目: 教程
-
女生“主动”与你分享这3个秘密?520%偷偷喜欢你,臭弟弟冲鸭
2026-05-14栏目: 教程
