PHP Classes

File: example/example_remove_comments.php

Recommend this page to a friend!
  Classes of Lars Moelleken  >  Simple HTML DOM  >  example/example_remove_comments.php  >  Download  
File: example/example_remove_comments.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Simple HTML DOM
Manipulate HTML elements using DOMDocument
Author: By
Last change: Update of example/example_remove_comments.php
Date: 11 months ago
Size: 550 bytes


Class file image Download

require_once '../vendor/autoload.php';

html_no_comment(string $html): string
// create HTML DOM
$dom = \voku\helper\HtmlDomParser::str_get_html($html);

// remove all comment elements
foreach ($dom->find('comment') as $e) {
$e->outertext = '';


// -----------------------------------------------------------------------------

$html = '
<!-- comment -->

// html without comments
echo html_no_comment($html);

For more information send a message to info at phpclasses dot org.