PHP Classes

File: example/example_modify_contents.php

Recommend this page to a friend!
  Classes of Lars Moelleken   Simple HTML DOM   example/example_modify_contents.php   Download  
File: example/example_modify_contents.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_modify_contents.php
Date: 1 year ago
Size: 402 bytes
 

Contents

Class file image Download
<?php

use voku\helper\HtmlDomParser;

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

// get DOM from URL or file
$html = HtmlDomParser::file_get_html('http://www.google.com/');

// replace all image
foreach ($html->find('img') as $e) {
   
$e->outertext = '<img src="foobar.png">';
}

// replace all input
foreach ($html->find('input') as $e) {
   
$e->outertext = '[INPUT]';
}

// dump contents
echo $html;