Home  >  Article  >  Backend Development  >  如何去除字符串最后一个<br/>

如何去除字符串最后一个<br/>

WBOY
WBOYOriginal
2016-06-23 14:16:191564browse

$str = "aaa
bbb
ccc
ddd
";


回复讨论(解决方案)

$str = "aaa
bbb
ccc
ddd
";
echo substr($str, 0, -5);

如果用查找的方式呢?查找到最后一个
后删除

$str = "aaa
bbb
ccc
ddd
";
echo substr($str, 0, -5);

$str = "aaa
bbb
ccc
ddd
";
echo substr($str, 0, -5); 我想找个跟chop类似的函数,只不过chop只能去除空格或预定义的

$str = "aaa<br/>bbb<br/>ccc<br/>ddd<br/>___";echo strrev(join('', explode('>/rb<', strrev($str), 2)));

aaa
bbb
ccc
ddd___

rtrim($str,"
");
chop不就是rtrim么?

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