在CakePHP中替换微软字符的最佳方式是什么?CakePHP - 替换微软字符
所以我试图在编辑或保存每个文本字段之前运行以下功能。
function convert_ms_chars($string)
{
$search = array(chr(145),
chr(146),
chr(147),
chr(148),
chr(151));
$replace = array("'",
"'",
'"',
'"',
'-');
return str_replace($search, $replace, $string);
}
我现在这样做的方式现在感觉超级贫民窟。
if (!empty($this->data)) {
$this->data['field'] = $this->convert_ms_chars($this->data['field']);
$this->data['field1'] = $this->convert_ms_chars($this->data['field1']);
}
更不用说我需要将它复制到多个控制器上。
有没有更好的方法可以解决这个问题?
感谢,
三通