我有一个字符串(使用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 Code: 'Â';
字符串示例:
fully serviced daily. Â Â Spend the evenings relaxing in the frie
@Whoughton的解决方案
<meta http-equiv="content-type" content="text/html; charset=utf-8">
答案 0 :(得分:6)
好的,我花了一点时间看它,我相信这应该会好一点:
$char = utf8_decode('this is a string with char in it  couple of times');
$r = utf8_decode('Â');
$upd = str_replace($r, '', $char);
这对我来说是:
Source: string(51) "this is a string with char in it  couple of times"
Function: str_replace('Â', '', $char)
Output: string(49) "this is a string with char in it couple of times"
删除旧答案......