PHP code example of bkuhl / php-selector
1. Go to this page and download the library: Download bkuhl/php-selector 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/ */
bkuhl / php-selector example snippets
$html = <<<HTML
<div id="article" class="block large">
<h2>Article Name</h2>
<p>Contents of article</p>
<ul>
<li>One</li>
<li>Two</li>
<li>Three</li>
<li>Four</li>
<li><a href="#">Five</a></li>
</ul>
</div>
HTML;
$dom = new \PHPSelector\Dom($html);
var_dump($dom->find('div#article.large'));
var_dump($dom->find('div > h2:contains(Article)'));
var_dump($dom->find('div p + ul'));
var_dump($dom->find('ul > li:first-child'));
var_dump($dom->find('ul > li ~ li'));
var_dump($dom->find('ul > li:last-child'));
var_dump($dom->find('li a[href=#]'));
composer