我有一个字符串(使用 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 Circumflex
字符串示例:
fully serviced daily. Â Â Spend the evenings relaxing in the frie
@Whoughton 的解决方案
<meta http-equiv="content-type" content="text/html; charset=utf-8">
最佳答案
好吧,我花了更多时间看它,我相信它应该会更好一些:
$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"
旧答案已删除...
关于php - 无法从字符串中删除特定字符。 PHP,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5427447/