我有一个来自数据库的字符串,其中包含特殊字符。
我需要从字符串中删除 "”foreign_language_keywords”"
。请注意特殊的 ”
,这会产生问题。
我用过这个:
$d_contents = str_replace(
"”foreign_language_keywords”",
"foreign_language_keywords",
$d_contents
);
但它返回的是同样的东西。
这是页面http://www.residentialstores.com/product_detail/bluetooth-keyboard--case-for-ipad-mini--qwerty-detachable-keyboard-flip-stand-black在我遇到问题的地方,我需要删除或隐藏描述中显示的外语关键字,如“Arabic- ......” 所有这些都在
标签中,标签的 ID 是“”foreign_language_keywords”,所以它变成了阿拉伯语- .....
我需要隐藏这个 p 标签最佳答案
您确定您的代码确实执行了 str_replace()
,还是之后您实际上在处理同一个字符串?
这两个在这里都可以正常工作:
#!/usr/bin/php
<?
$d_contents = "<p><strong>
<p id='”foreign_language_keywords”'>Arabic - الحال بالنسبة
لأي باد ميني مع لوحة مفاتيح bluetooth قابلة للنزع; Chinese
Simplified - 可拆卸的蓝牙��盘与 iPad 迷你的情况; Czech ... ";
$d_contents = str_replace("”", "", $d_contents);
print "$d_contents\n";
或使用:
$d_contents = str_replace(
"”foreign_language_keywords”",
"foreign_language_keywords",
$d_contents
);
关于javascript - 需要从字符串 php 中删除这个特殊字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21601580/