html过滤描述内容保留换行和原来的样式怎么办?
function dr_clearhtml($str) {
$str = str_replace(
array(' ', '&', '"', ''', '“', '”', '—', '<', '>', '·', '…'), array(' ', '&', '"', "'", '“', '”', '—', '<', '>', '·', '…'), $str
);
$str = preg_replace("/\<[a-z]+(.*)\>/iU", "", $str);
$str = preg_replace("/\<\/[a-z]+\>/iU", "", $str);
$str = str_replace(array(PHP_EOL, chr(13), chr(10), ' '), '', $str);
$str = strip_tags($str);
return trim($str);
}
}这个代码怎么改保留换行和原来的样式
function dr_custom_html($str) { $str = str_replace( array(' ', '&', '"', ''', '“', '”', '—', '<', '>', '·', '…'), array(' ', '&', '"', "'", '“', '”', '—', '<', '>', '·', '…'), $str ); $str = str_replace(array(PHP_EOL, chr(13), chr(10), ' '), '', $str); $str = strip_tags($str); return trim($str); }custom.php定一个dr_custom_html 新函数但是还是去掉换行和 <p dir="rtl" style="text-align: right;"> 这个样式对我来说重要的保留<p dir="rtl" style="text-align: right;"> 这个样式