php移除Remove Microsoft Word HTML Tag
2016-06-22 21:09
483 查看
当你使用Microsoft Word会创建许多Tag,比如font,span,style,class等。这些标签对于Word本身而言是非常有用的,但是当你从Word粘贴至网页时,你会发现很多无用的Tag。因此,下面的这段代码可帮助你删除所有无用的Word HTML Tag。
function cleanHTML($html) { /// <summary> /// Removes all FONT and SPAN tags, and all Class and Style attributes. /// Designed to get rid of non-standard Microsoft Word HTML tags. /// </summary> // start by completely removing all unwanted tags $html = ereg_replace("<(/)?(font|span|del|ins)[^>]*>","",$html); // then run another pass over the html (twice), removing unwanted attributes $html = ereg_replace("<([^>]*)(class|lang|style|size|face)=("[^"]*"|'[^']*'|[^>]+)([^>]*)>","<\1>",$html); $html = ereg_replace("<([^>]*)(class|lang|style|size|face)=("[^"]*"|'[^']*'|[^>]+)([^>]*)>","<\1>",$html); return $html }
相关文章推荐
- php检测浏览器语言
- php自动转换URL,跳转至超链接
- php查找页面上的所有链接
- PHP——=> ->
- php代码查看邮件是否已被阅读
- PHP中9大缓存技术
- 并发下常见的加锁及锁的PHP具体实现代码(转)
- 基于Php mysql存储过程的详解
- ThinkPHP框架表单验证
- php mysql 分开(分离)搭建lamp环境
- PHP实现文件下载
- YII 框架学习[1] —— 引入Yii框架
- laravel5.2.36 Request验证类错误输出不显示问题
- thinkphp 笔记
- cookie中文乱码解决(php/js)
- 使用php脚本查看已开启的扩展
- PHP 时间函数
- Yii 一些小的问题
- php文件上传
- PHP中in_array 效率优化