Created
September 24, 2015 15:21
-
-
Save LiamBailey/e41b03e62368bb71c8ce to your computer and use it in GitHub Desktop.
Strips out html (person importing content from Blogger)
This file contains 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
<?php | |
$content = strip_tags($_POST['content'],"<p><br><a>"); | |
lib_xml_use_internal_errors(true); | |
$DOM = new DOMDocument($content); | |
foreach($dom->getElementsByTagName($tagname) as $tag) { | |
if ($tag->hasAttributes()) { | |
foreach($tag->attributes as $attribute) { | |
if ($attribute->nodeName !== "href") | |
$tag->removeAttribute($attribute->nodeName); | |
} | |
} | |
} | |
$newContent = $dom->saveHTML(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment