Reputation: 15007
I am trying to parse html and I have a string which has weird quotes:
‘3’
How do I convert their character-encoding to the regular '
?
Upvotes: 2
Views: 489
Reputation: 137398
Shamelessly taken from Convert Smart Quotes back to normal:
<?php
function convert_smart_quotes($string) {
//converts smart quotes to normal quotes.
$search = array(chr(145), chr(146), chr(147), chr(148), chr(151));
$replace = array("'", "'", '"', '"', '-');
return str_replace($search, $replace, $string);
}
?>
Found via: "php convert curly quotes".
Upvotes: 3