PHP 在PHP中替换MS智能引号
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PHP 在PHP中替换MS智能引号相关的知识,希望对你有一定的参考价值。
<?
$string="Steve�s fix for MicroSux �Smart Quotes�";
print "Original |$string|<br>";
echo "Final " . fix_ms_smart_quotes($string) ."<br>";
function fix_ms_smart_quotes($string) {
$text = str_replace(
array("\xe2\x80\x98", "\xe2\x80\x99", "\xe2\x80\x9c", "\xe2\x80\x9d", "\xe2\x80\x93", "\xe2\x80\x94", "\xe2\x80\xa6"),
array("'", "'", '"', '"', '-', '--', '...'),
$string);
// Next, replace their Windows-1252 equivalents.
$text = str_replace(
array(chr(145), chr(146), chr(147), chr(148), chr(150), chr(151), chr(133)),
array("'", "'", '"', '"', '-', '--', '...'),
$text);
return $text;
}
?>
以上是关于PHP 在PHP中替换MS智能引号的主要内容,如果未能解决你的问题,请参考以下文章
如何在 php 中为 tsql 字符串转义单引号(ms sql)
用其他东西替换或删除新行,但只能在 CSV 文件上使用 PHP 的单引号或双引号之间
使用 PHP 转换所有类型的智能引号
PHP 替换html标签内的单引号,将单引号替换成双引号
是否有任何在线工具可用于将无效 JSON 中的单引号替换为双引号或在 PHP 中使用无效 json 的任何解决方案?
从 MS Excel 生成的 php CSV 导入