日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

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

發布時間:2023/12/1 43 豆豆
生活随笔 收集整理的這篇文章主要介紹了 php 去除 html 属性,用PHP 去掉所有html标签里的部分属性 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

用PHP 去掉所有html標簽里的部分屬性

http://zhidao.baidu.com/question/418471924.html

用PHP 去掉所有html標簽里的部分屬性 tppabs

set_time_limit(0);

function view_dir($dir)

{

$dp=opendir($dir); //打開目錄句柄

//echo "
".$dir."
";

$path2='';

while ($file = readdir($dp)) //遍歷目錄

{

if ($file !='.'&&$file !='..') //如果文件不是當前目錄及父目錄

{

$path=$dir."/".$file; //獲取路徑

if(is_dir($path)) //如果當前文件為目錄

{

view_dir($path); //遞歸調用

}

else //如果不是目錄

{

//echo '

$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 '

'.$path.'';

//echo '

復制至XX';

//echo '

刪除';

//echo '';

//echo '

';

}

}

}

return $path2."\r\n";

closedir($dp);

}

$dir='E:book\chigb\x';

echo view_dir($dir);

$file='

文字1 文字2 文字3

';

$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("

總結

以上是生活随笔為你收集整理的php 去除 html 属性,用PHP 去掉所有html标签里的部分属性的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。