Reputation: 2236
So the characters “ and ” (“
and ”
respectively) are variations of the neutral quote ("). I see them in a data sheet I have that is full of html and am trying to find and replace them using php.
First, I am testing to see how to reproduce it. Here is my php code:
<?php
echo chr(8220);
?>
Why doesn't this work? I have tried other numbers in the char()
function and it worked fine. I have tried setting the character set to UTF-8
and ISO-8859-1
but it didn't work. How do I make this echo the quote?
I am trying to echo it because I am trying to integrate it into the php code. I know I can just copy and paste it but that will be too confusing to me.
Upvotes: 1
Views: 400
Reputation: 5331
Try charset=WINDOWS-1252"
<meta http-equiv="content-type" content="text/html; charset=WINDOWS-1252" >
Upvotes: 0
Reputation: 8767
Try:
$str = str_replace(chr(147), '"', $str); // left double quote
$str = str_replace(chr(148), '"', $str); // right double quote
Where 147
and 148
respectively equal left and right double quotes.
Upvotes: 2
Reputation: 3024
Have you tried the function mb_convert_encoding?
See this explanation on the php docs for how to get the character from its html encoding. Here is the function that that person defined (directly copied from that link):
function unichr($u) {
return mb_convert_encoding('&#' . intval($u) . ';', 'UTF-8', 'HTML-ENTITIES');
}
Upvotes: 0