无法从字符串中删除某些字符。 PHP
我有一个字符串(使用 cURL 从另一个网站检索)。使用该字符串,我尝试将某个字符替换为空,没有空格,只需删除它。
foreach($propinfo_desc_div as $child)
{
// ONLY SHOW STRINGS LONGER THAN 10 CHARS
$strlen = strlen($child->nodeValue);
if($strlen > 10)
{
$description = str_replace(htmlspecialchars('Â'),'', $child->nodeValue);
echo $description;
echo "<br />";
}
}
有关该字符的一些信息:
- ASCII 字符:
ASCII 代码: 'Â';
- ASCII 描述:拉丁大写字母 A 抑扬符
字符串示例:
fully serviced daily. Â Â Spend the evenings relaxing in the frie
@Whoughton 的解决方案
<meta http-equiv="content-type" content="text/html; charset=utf-8">
I have a string(retrieved from another website using cURL. With the string I am trying to replace a certain character with nothing, no space, just get rid of it.
foreach($propinfo_desc_div as $child)
{
// ONLY SHOW STRINGS LONGER THAN 10 CHARS
$strlen = strlen($child->nodeValue);
if($strlen > 10)
{
$description = str_replace(htmlspecialchars('Â'),'', $child->nodeValue);
echo $description;
echo "<br />";
}
}
Some info on the character:
- ASCII Char: Â
ASCII Code: 'Â';
- ASCII Description: Latin Capital Letter A Circumflex
string example:
fully serviced daily. Â Â Spend the evenings relaxing in the frie
Solution by @Whoughton
<meta http-equiv="content-type" content="text/html; charset=utf-8">
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,我花了更多的时间看它,我相信这应该会更好一点:
这对我来说:
旧答案已删除...
Ok, I spent a little more time looking at it, I believe this should work a little better:
This produces, for me:
Old answer removed...