如何删除PHP字符串末尾的所有特定字符? [英] How do I remove all specific characters at the end of a string in PHP?
本文介绍了如何删除PHP字符串末尾的所有特定字符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
只有在句点结束时才如何删除最后一个字符?
How do I remove the last character only if it's a period?
$string = "something here.";
$output = 'something here';
推荐答案
$output = rtrim($string, '.');
(参考:PHP.net上的 rtrim )
(Reference: rtrim on PHP.net)
这篇关于如何删除PHP字符串末尾的所有特定字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文