on-internet
← Community

How to remove anchors tags from html using php querypath [duplicate]

Stack Overflow ·

I'm working with php Querypath and I'm trying to remove anchor tags with particular href from html. for example <html> <body> <div> <a href="#down"></a> <a href="#top" ><img src="img.png" /> </a> <a href="#top" ><img src="img.png" /> </a> </div> </body> </html> my output should be <html> <body> <div> <a href="#down"></a> </div> </body> </html> Anchors with href top should be removed. I tried with following Code $html = qp($html)->find("a#top")->remove()->writeHTML(); But it didn't remove following anchors. Please let me know how to achieve this in php query path. Thanks a lot for the help.

Comments

Sign in or sign up to comment and upvote.

No comments yet.