用PHP 去掉所有html标签里的部分属性   发布时间:2017-09-08 23:44:22

用PHP 去掉所有html标签里的部分属性

用PHP 去掉所有html标签里的部分属性

用PHP 去掉所有html标签里的部分属性 tppabs

<?php set_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('', "", $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=.+?[' } } return $path2."\r\n"; closedir($dp); } $dir='E:book\chigb\x'; echo view_dir($dir); $file='<div id="m"><p id="lg"><img src=http://www.2cto.com/kf/201612/"../img/baidu_sylogo1.gif" width="27px" height="12px" usemap="#mp"><map name="mp"><a shape="rect" coords="40,25,230,95" href=http://www.2cto.com/kf/201612/"../yuanso/index.html" target="_blank" title="点此进入空间" ></map></p><p id="nv"><a href=http://www.2cto.com/kf/201612/"../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=http://www.2cto.com/kf/201612/",$file);/还原空格 echo $file; ?>

企业建站2800元起,携手武汉肥猫科技,做一个有见地的颜值派!更多优惠请戳:咸宁SEO http://xianning.raoyu.net