getElementsByTagName('a'); foreach($ahrefs as $element){ for ( $k = $element->attributes->length - 1; $k >= 0; --$k) { if( array_search( $element->attributes->item($k)->nodeName, $allowed_attributes ) === false || ( $element->attributes->item($k)->nodeName == 'target' && array_search( $element->attributes->item($k)->nodeValue, $allowed_target) === false) ){ $element->removeAttributeNode( $element->attributes->item($k)); } } } return $doc; } public function getNecessaryScripts() { return $this->necessary_scripts; } }