用PHP 去掉所有html标签里的部分属性
用PHP 去掉所有html标签里的部分属性
http://zhidao.baidu.com/question/418471924.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('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;
?>
用PHP 去掉所有html标签里的部分属性的更多相关文章
- script标签里的defer属性
入职新公司,看代码的时候注意到有的script标签中有一个defer属性,查了一下.在这里分享出来. 需要注意的有三点,其中前两点是在错误中分辨出来的: 错误来源:http://www.w3schoo ...
- 用js动态的改变img标签里面的src属性实现图片的循环切换
JS:根据循环切换的条件可以用 document.getElementById('').src=''设置, 或者jquery方法: $('#id').attr('src','图片名称’): 具体: i ...
- 在<s:iterator>标签里给动态表格添加序号
在<s:iterator>标签里给动态表格添加序号,需要用到<s:iterator>标签里的Status属性里的count eg:<s:iterator value=&q ...
- 将javascript函数写在Html标签里
有些时候不想把函数写在script标签里了,想直接在html标签里直接加上js代码,可以这样写: <body onload="javascript:{window.location.h ...
- 如何在一个div标签里显示出另一个网页? <iframe src=" http://www.baidu.com " width="800px" height="200px" scrolling="no" frameborder="0"> </iframe>
如何在一个div标签里显示出另一个网页? 用在div里用iframe,就像下面的代码 <iframe src=" http://www.baidu.com " width=& ...
- Asp.Net正则获取页面a标签里的内容
Asp.Net正则获取页面a标签里的内容 string url = "http://www.114369.com"; string html = MyCLib.NetClass.S ...
- 火狐下<a>标签里嵌套的<select>不能选的bug
今天遇到了这个问题,网上一找就找到原因了:在狐火下<a>标签里嵌套的<select>不能选 可是我查找这个问题过程中依然饶了一些时间,原因是在<a>标签没有写hre ...
- img标签里的value获取
简单描述:在img标签里的value存放了需要用到的值,但是在js中获取的时候,我直接写的就是$("#imgStr").val(),结果发现是空,后来查了一下,才知道,img的va ...
- 对<tr><td>标签里的input 循环取值
需求描述:单击table整行,跳转到具体的信息页面 关键就是获取整行的id,传给后台做查询,返回list 解决思路:用带参数函数传过去id,然后在js的函数中用$("#id"). ...
随机推荐
- vue-router学习例子分享
http://blog.csdn.net/bboyjoe/article/details/52804988 <!DOCTYPE html> <html lang="en&q ...
- How Blink works
How Blink works Author: haraken@ Last update: 2018 Aug 14 Status: PUBLIC Working on Blink is not eas ...
- Ubuntu16.04安装java(Oracle jre)
一.安装1.从Oracle官网下载jre-8u161-linux-x64.tar.gz安装文件(下载与浏览器位数一样) 2.切换到所需的安装目录.键入: pipci@ubuntu:~$ cd /usr ...
- javaScript 对象学习笔记
javaScript 对象学习笔记 关于对象,这对我们软件工程到学生来说是不陌生的. 因为这个内容是在过年学到,事儿多,断断续续,总感觉有一丝不顺畅,但总结还是要写一下的 JavaScript 对象 ...
- weex入门(一)
emmmm其实没有接触过weex ,了解一番发现有很多坑,有很多基于weex改良后的框架,比如weexplus等等,基本不用踩多少坑.经过几天的深思熟虑我觉得还是去踩坑,毕竟踩完坑才能真正的了解嘛 w ...
- 【RHEL7/CentOS7网络配置】
目录 网卡配置文件 查网卡信息 测试网络是否正常 使用 nmtui 命令配置网络 使用 nm-connection-editor 工具配置网络 修改回6.x版本的网卡名 Rhel/CentOS网络配置 ...
- @Mapper 和 @MapperScan 区别
1.@Mapper : 为了使接口被其他类引用,需要使用@Mapper注解,这种方式要求每一个mapper类都需要添加此注解,麻烦. package com.example.demo.dao; imp ...
- js 图片轮转
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- Torch 的安装与基本用法
本文安装仅限 ubuntu 系统.官方文档见:Getting started with Torch. 0. 简介 Torch 使用轻量级脚本语言 Lua 及其 C/CUDA 扩展模块实现,底层数值计算 ...
- 55.npm install 报错 :stack Error: Can't find Python executable "python"
转自:https://www.cnblogs.com/zengry/p/8044379.html 解决方法 : 1. 安装python , 设置环境变量 :cmd --> path='%path ...