query($query); $allowed_attributes = ['class', 'id']; foreach($entries as $element){ for ( $k = $element->attributes->length - 1; $k >= 0; --$k) { if( array_search( $element->attributes->item($k)->nodeName, $allowed_attributes ) === false ){ $element->removeAttributeNode( $element->attributes->item($k)); } } } $ahrefs = $doc->getElementsByTagName('p'); foreach($ahrefs as $element){ for ( $k = $element->attributes->length - 1; $k >= 0; --$k) { $element->removeAttributeNode( $element->attributes->item($k)); } } return $doc; } public function getNecessaryScripts() { return $this->necessary_scripts; } }