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

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

WBOY
Release: 2016-06-23 13:42:30
Original
1056 people have browsed it

  <?php  $str='left.htm';     $str=rtrim($str,'.htm');     echo $str;
Copy after login

输出结果为lef。
怎么解决这个问题???????


回复讨论(解决方案)

用str_replace 替换得了。

因为 rtrim 的第二个参数是字符列表,而不是字符串

lef t.htm 的 t 也在列表 .h tm 中,当然也会被删掉

trim 的第二个参数是charlist 表示字符的集合 left的t在'.htm'中


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

$file = "left.htm";

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









$str='left.htm';echo substr($str,0,strpos($str,'.'));
Copy after login

source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template