PHP Classes
elePHPant
Icontem

File: example/example_remove_content.php

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

 

Contents

Class file image Download
<?php

use voku\helper\HtmlDomParser;

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

$templateHtml = '
<p>lall<br></p>
<ul><li>test321<br>test123</li></ul>
'
;

// remove: "<br>" from "<ul>"
$htmlTmp = HtmlDomParser::str_get_html($templateHtml);
foreach (
$htmlTmp->find('ul br') as $br) {
 
$br->outertext = '';
}

$templateHtml = $htmlTmp->save();

// dump contents
echo $templateHtml;