-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