我正在处理旧代码,却遇到了-失败:检查并替换字符串部分
private function CleanHtml($string, $lenght)
{
$string = strip_tags($string);
$string = substr($string,0,$lenght);
$search = array ("'<script[^>]*?>.*?</script>'si",
"'<[\/\!]*?[^<>]*?>'si",
"'([\r\n])[\s]+'",
"'([\r])+'",
"'([\n])+'",
"'&(quot|#34);'i",
"'&(amp|#38);'i",
"'&(lt|#60);'i",
"'&(gt|#62);'i",
"'&(nbsp|#160);'i",
"'&(iexcl|#161);'i",
"'&(cent|#162);'i",
"'&(pound|#163);'i",
"'&(copy|#169);'i",
"'&#(\d+);'e");
$replace = array (
"",
"",
"",
"",
"",
"",
"&",
"<",
">",
" ",
chr(161),
chr(162),
chr(163),
chr(169),
"chr(\\1)");
$description = preg_replace_callback($search, $replace, $string);
return $description;
}
因为它给我错误“ preg_replace_callback():要求参数2'Array'是有效的回调”?