Cannot remove certain character from a string. PHP
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">
Ok, I spent a little more time looking at it, I believe this should work a little better:
$char = utf8_decode('this is a string with char in it  couple of times');
$r = utf8_decode('Â');
$upd = str_replace($r, '', $char);
This produces, for me:
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"
Old answer removed...
精彩评论