我使用:刪除與preg_replace函數<a>聯繫,但保持<img>圖像內
$this->tresc[$i][description]=preg_replace("/\<a .*\>.*\<\/a\>/i", "", $this->tresc[$i][description]);
刪除鏈接。
有時鏈接裏面有我的圖像想保留:
<a href="http://www.domain.com/page.php"><img src="http://domain.com/image.jpg" alt="Image" align="left" /></a>
這可能嗎?現在刪除了所有在<a>
和</a>
之間的內容。
[不要使用正則表達式來解析HTML](http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454#1732454) – 2012-07-08 14:09:04
I解析RSS提要。 – Spacedust 2012-07-08 14:09:55
猜猜它是什麼。 – Ryan 2012-07-08 14:10:09