Created
March 2, 2017 12:04
-
-
Save khaledMohammed000/37fc49029c492d71ce05a8d9a8bb5bd0 to your computer and use it in GitHub Desktop.
DOM traversal in PHP backend
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // removing attribute href and width from divs | |
| // for html code go here for testing : http://pastebin.com/ZBwEJsQ8 | |
| $dom = new DOMDocument; | |
| $dom->loadHTML($content); | |
| $divs = $dom->getElementsByTagName('div'); | |
| foreach ($divs as $div) { | |
| $div->removeAttribute('href'); | |
| $div->removeAttribute('width'); | |
| } | |
| $content = $dom->saveHTML(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment