Home  >  Article  >  php教程  >  php rtrim(),substr()删除字符串最一个字符

php rtrim(),substr()删除字符串最一个字符

WBOY
WBOYOriginal
2016-06-13 11:18:39832browse

 

我们利用这两个函数来删除字符串最后一个字符是有说法的,rtrim他有默认删除空格和一些特殊字符,但你也可以删除指定字符,页substr我们是取字符长度,自然只要取字符长度减一就行了如下实例。
*/

$str ='abcea';
echo rtrim($str,'a');


//方法二

echo '
'.substr($str,0,strlen($str)-1);


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