PHP code example of larammerce / html-dom

1. Go to this page and download the library: Download larammerce/html-dom library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

larammerce / html-dom example snippets


'providers' => array(
    ...
	'Larammerce\HtmlDom\HtmlDomServiceProvider',
    ...

'aliases' => array(	
    ...
	'HtmlDom' => 'Larammerce\HtmlDom\HtmlDom',
    ...

$html = new \HtmlDom('http://www.example.com');

// Find all images 
foreach($html->find('img') as $element) 
       echo $element->src . '<br>';

// Find all links 
foreach($html->find('a') as $element) 
       echo $element->href . '<br>';