用PHP 去掉所有html标签里的部分属性
来源:互联网 发布:app客户端制作软件 编辑:程序博客网 时间:2024/05/01 13:39
用PHP 去掉所有html标签里的部分属性http://zhidao.baidu.com/question/418471924.html用PHP 去掉所有html标签里的部分属性 tppabs <?phpset_time_limit(0);function view_dir($dir){$dp=opendir($dir); //打开目录句柄//echo "<br>".$dir."<br><br>"; $path2='';while ($file = readdir($dp)) //遍历目录{ if ($file !='.'&&$file !='..') //如果文件不是当前目录及父目录 { $path=$dir."/".$file; //获取路径 if(is_dir($path)) //如果当前文件为目录 { view_dir($path); //递归调用 } else //如果不是目录 {//echo '<tr><td><table width="100%" border="0" cellspacing="0" cellpadding="0">'; $path2 .= $path."\r\n"; $c=file_get_contents($path);// $c = str_replace('http://4.28.99.196/chigb', "", $c);// $c1=array(' tppabs="/style/book.css" rel="stylesheet"',' tppabs="/chigb/up.gif"',' tppabs="/chigb/1pix.gif"',' tppabs="/chigb/left.gif"',' tppabs="/chigb/right.gif"');// $c2 = str_replace($c1, "", $c);$del=array("/tppabs=.+?['|\"]/i");$c2 = preg_replace($del,"",$c); $c2 = str_replace('" >', '">', $c2); file_put_contents($path,$c2);//echo '<td width="52%" height="25"><a href="'.$path.'">'.$path.'</a></td>';//echo '<td width="17%" align="center"><a href='.$_SERVER['SCRIPT_NAME'].'?cp='.$path.'> 复制至XX</a></td>';//echo '<td width="31%" align="center"><b><a href='.$_SERVER['SCRIPT_NAME'].'?cmd=del&name='.$path.'>删除</a></b></td>';//echo '</tr>';//echo '</table></td></tr>'; } }}return $path2."\r\n";closedir($dp);} $dir='E:book\chigb\x';echo view_dir($dir);$file='<div id="m"><p id="lg"><img src="../img/baidu_sylogo1.gif" width="27px" height="12px" usemap="#mp"><map name="mp"><a shape="rect" coords="40,25,230,95" href="../yuanso/index.html" target="_blank" title="点此进入空间" ></map></p><p id="nv"><a href="../yuanso/index1.html">文字1</a> <b>文字2</b> <a href="../yuanso/index3.html">文字3</a></p></div>';$del=array("/name=.+?['|\"]/i","/src=.+?['|\"]/i","/id=.+?['|\"]/i","/width=.+?['|\"]/i","/height=.+?['|\"]/i","/usemap=.+?['|\"]/i","/shape=.+?['|\"]/i","/coords=.+?['|\"]/i","/target=.+?['|\"]/i","/title=.+?['|\"]/i");$file = preg_replace($del,"",$file);//去除style样式$file = str_replace(" ","",$file);//去除所有空格$file = str_replace("<ahref=","<a href=",$file);//还原空格echo $file;?>
0 0
- 用PHP 去掉所有html标签里的部分属性
- 怎么用PHP正则 去掉所有html标签的属性部分
- JAVA去掉字符串里的html标签。
- 去掉字符里的html标签
- PHP去掉指定的html标签
- PHP去掉指定的html标签 .
- jQuery去掉指定标签里所有文字内容对应的链接,==去掉<a>标签
- 将内容里的html标签去掉的类
- 通过js去掉所有的html标签,得到HTML标签中的所有内容
- 去掉img标签里的width 和 height的属性
- 去掉html源代码里标签之间的空格和换行
- 张坤 2012.5.4 sed去掉所有的HTML标签
- PHP中去掉HTML标签
- 去掉HTML的标签
- 去掉内容中的所有全部html标签。
- 去掉内容中的所有html标签
- 去掉内容中的所有全部html标签
- java正则表达式去掉所有HTML标签
- 网站添加天气预报功能
- STM32移植RT-Thread后的串口在调试助手上出现:(mq != RT_NULL) assert failed at rt_mq_recv:2085和串口只发送数据不能接收数据问题
- 服务器开发之junit多线程测试
- js三级联动
- Java 重写(Override)与重载(Overload)——面向对象
- 用PHP 去掉所有html标签里的部分属性
- 修改chrome的安装目录(默认的竟然安装在documents and settings目录,google真不厚道)
- PHP+Ajax+Mysql联合实现省市区三级联动
- BE插件开发获取当前单据状态枚举
- 2012年流行的安卓手机浏览器
- java collection map遍历效率问题
- Android5.1-s5p6818平台Android.mk文件引入so动态库问题
- 命名污染
- Bootstrap-3.3.7