I have some records on my table and as I can see it on PHPMyAdmin it contains apostrophe like this:
Brazil’s ‘car wash’
When I make a query and echo them on web page without any header these apostrophes appear as question marks like this:
Brazil�s �car wash�
but with this header:
header("Content-Type: text/html; charset=ISO-8859-1");
they appear correctly.
Now the problem, I cannot replace them using this code:
$title = str_replace('’',"",$title);
$title = str_replace("‘","",$title);
How can I replace those apostrophes if str_replace not working?
This indicates your data is stored in ISO encoding, while the default encoding of your webpage might be UTF-8 or something else. Why replace them? You could convert your data to UTF-8 prior outputting or change the whole site encoding to ISO. But I would always prefer UTF-8.
You can convert to UTF-8 with $title = utf8_encode($title)
.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments