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

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

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-13 11:18:39
Original
921 people have browsed it

 

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

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


//方法二

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


Statement of this Website
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template