php正则匹配或者str_replace如何对英文的 度 这个符号进行替换?

WBOY
Release: 2016-06-23 14:03:56
Original
974 people have browsed it

想把英文 度 这个特殊符号转为"",一直没调好怎么写,有人知道吗?求助啊,谢谢!


回复讨论(解决方案)

额 咋没人解答呢

你直接上一下代码吧,让我们看看哪里有问题

"zgy 90°"就是想把这个字符串的度数符号去掉啊

代码1

$str="zgy 90°";echo str_replace('°', '', $str);
Copy after login

$str="dfdfsdsf&deg;&deg;&deg;&deg;zgy&deg;&deg;&deg;&deg; 90&deg;";echo str_replace('&deg;', '', $str)."<br>";echo preg_replace('/(&deg;)+/', '', $str);
Copy after login

奇怪刚才我也用的str_replace,结果就不对呢,按照你给的这个就解决了
多谢了!

字符集问题!

新建文档,改后缀名为php的话,这个文件是不是默认还是gb2312编码啊,总是得转为utf-8编码,特殊符号才显示出来

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