将特殊报价转换为常规报价

时间:2013-01-21 08:58:53

标签: php character-encoding

我正在尝试解析html,并且我有一个带有奇怪引号的字符串:

‘3’

如何将字符编码转换为常规'

1 个答案:

答案 0 :(得分:3)

无耻地从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);
}
?>

通过:"php convert curly quotes"找到。