1.去掉转义和html标签
$newContent = strip_tags(stripslashes($_POST['content']));2.取掉两边多余的空格
$newContent = trim($newContent);$patternArr = array('/\s/','/ /');
$replaceArr = array('','');
$newContent = preg_replace($patternArr,$replaceArr,$newContent);4.截取固定的长度
$newContent = mb_strcut($newContent,0,150,'utf-8');
本文介绍了一种高效的方法来处理HTML内容,包括去除转义字符、HTML标签、多余空格,以及固定内容长度。通过使用PHP函数如strip_tags、stripslashes、trim、preg_replace和mb_strcut,实现对输入内容的清理和限制,确保数据安全性和一致性。
2203

被折叠的 条评论
为什么被折叠?



