I have an HTML string containing characters, for some reason I cannot replace them. I assume this is an encoding problem, although I cannot figure out how to do this. Site uses ISO-8859-1 to encode it.
$str = '<span class="price">£89.99</span>'; var_dump(mb_detect_encoding($str, 'ISO-8859-1', true)); // outputs ISO-8859-1 echo str_replace(array("£","£"),"",$str); // nothing is removed echo htmlentities($str); // the entire string is converted, including £ to £
Any ideas?
EDIT
should have indicated that I want to replace £ with £ ; - I temporarily added £ to the array of elements to replace if it has already been converted
robjmills
source share