我想刪除我的domdocument html中的元素標記。操縱PHP domdocument字符串
我有類似
this is the <a href='#'>test link</a> here and <a href='#'>there</a>.
我想我的HTML改爲
this is the test link here and there.
我的代碼
$dom = new DomDocument();
$dom->loadHTML($html);
$atags=$dom->getElementsByTagName('a');
foreach($atags as $atag){
$value = $atag->nodeValue;
//I can get the test link and there value but I don't know how to remove the a tag.
}
感謝您的幫助!
您正在尋找名爲['DOMNode :: replaceChild()'](http://php.net/DOMNode.replaceChild)的方法。 – hakre