Home >Backend Development >PHP Tutorial >php rtrim函数在处理时去掉字符t是咋回事

php rtrim函数在处理时去掉字符t是咋回事

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-13 12:12:561138browse

php rtrim函数在处理时去掉字符t是怎么回事啊

<br />  <?php  $str='left.htm';<br />     $str=rtrim($str,'.htm');<br />     echo $str;<br />

输出结果为lef。
怎么解决这个问题???????
------解决思路----------------------
用str_replace 替换得了。
------解决思路----------------------
因为 rtrim 的第二个参数是字符列表,而不是字符串

left.htm 的 t 也在列表 .htm 中,当然也会被删掉
------解决思路----------------------
trim 的第二个参数是charlist   表示字符的集合    left的t在'.htm'中


如果只是取得文件名字  用basename即可

$file = "left.htm";

echo basename($file,'.htm');//left










------解决思路----------------------
<br />$str='left.htm';<br />echo substr($str,0,strpos($str,'.'));<br />

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