-1
使用PHP和正则表达式,如何从标签中去除所有不需要的样式,类或其他垃圾?从指定的html标签中删除类/样式/垃圾
EG:
<span class="blah" style="blah" any other junk >...</span>
将被清洗,这一点:<span>...</span>
。
我试图把一个函数像这样:
function cleanTag($html, $tagType='div'){
$html = // regex to clean out all tags of $tagType in $html
return $html;
}
我想这对我设置为$tagType
任何标签类型的工作。
需要在PHP中 - 我在做服务器端。谢谢。
其他可能的重复项:https://stackoverflow.com/questions/4179206或https://stackoverflow.com/questions/12104962或https://stackoverflow.com/questions/6371527 。还可以查看更多相关部分。 – Gordon