Skip to content

Instantly share code, notes, and snippets.

@pagelab
Created October 12, 2021 17:35
Show Gist options
  • Save pagelab/b160b39cc48c07a7e30edb8cdeefc457 to your computer and use it in GitHub Desktop.
Save pagelab/b160b39cc48c07a7e30edb8cdeefc457 to your computer and use it in GitHub Desktop.
DOMDocument: como remover tags <style> de uma string com código HTML.
<?php
// Remover tags style do HTML.
$dom = new DOMDocument();
$dom->preserveWhiteSpace = false;
$dom->loadHTML( $content );
$styles = $dom->getElementsByTagName( 'style' );
while( $styles->length > 0 ) {
$style = $styles->item(0);
$style->parentNode->removeChild( $style );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment