你所在的位置:首 页 >> php编程 >> 详细新闻页面


php 去除html标签 和 css样式

作者:zhirong1230 创建时间:2012-06-15 阅读次数:5088


php 去除html标签 和 css样式

Php代码 

   $content = preg_replace("/<a[^>]*>/i", "", $content);   
   $content = preg_replace("/<\/a>/i", "", $content);   
   $content = preg_replace("/<div[^>]*>/i", "", $content);  
   $content = preg_replace("/<\/div>/i", "", $content);         
   $content = preg_replace("/<!--[^>]*-->/i", "", $content);//注释内容   
   $content = preg_replace("/style=.+?['|\"]/i",'',$content);//去除样式  
   $content = preg_replace("/class=.+?['|\"]/i",'',$content);//去除样式  
   $content = preg_replace("/id=.+?['|\"]/i",'',$content);//去除样式     
   $content = preg_replace("/lang=.+?['|\"]/i",'',$content);//去除样式      
   $content = preg_replace("/width=.+?['|\"]/i",'',$content);//去除样式   
   $content = preg_replace("/height=.+?['|\"]/i",'',$content);//去除样式   
   $content = preg_replace("/border=.+?['|\"]/i",'',$content);//去除样式   
   $content = preg_replace("/face=.+?['|\"]/i",'',$content);//去除样式   
   $content = preg_replace("/face=.+?['|\"]/",'',$content);
   //去除样式 只允许小写 正则匹配没有带 i 参数 


    关键词(keywords):php去除html标签,php去除css样式

分享到: 更多


前一篇: PHP计算两个时间之差的函数            后一篇:防止查看源代码的方法

phpchina   php爱好者   php100    中国网管联盟   LAMP兄弟连   河北联合大学   胜芳趣团网   rss 联系我们 问题反馈
版权所有@:ABCMS新闻发布系统!
建议使用ie6、ie8和 ff 浏览器进行浏览 | 建议分辨率:1024x768
地址:唐山市路北区高新技术产业园区龙华道128号 | 邮编:63000| 邮箱:zhirong1230@yeah.net