无法从字符串中删除某些字符.PHP

Jam*_*ars 3 php special-characters

我有一个字符串(使用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 />";
    }
}
Run Code Online (Sandbox Code Playgroud)

关于角色的一些信息:

  • ASCII字符:Â
  • ASCII Code: '&#194';
  • ASCII描述:Latin Capital Letter A Circumflex

字符串示例:

 fully serviced daily. Â Â Spend the evenings relaxing in the frie
Run Code Online (Sandbox Code Playgroud)

@Whoughton解决方案

<meta http-equiv="content-type" content="text/html; charset=utf-8">
Run Code Online (Sandbox Code Playgroud)

who*_*ton 6

好吧,我花了一点时间看它,我相信这应该会好一点:

$char = utf8_decode('this is a string with char in it  couple of times');
$r = utf8_decode('Â');
$upd = str_replace($r, '', $char);
Run Code Online (Sandbox Code Playgroud)

这对我来说是:

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"
Run Code Online (Sandbox Code Playgroud)

旧答案删除了......