2017 © Pedro Peláez
 

library php-selector

image

bkuhl/php-selector

  • Friday, October 13, 2017
  • by bkuhl
  • Repository
  • 1 Watchers
  • 7 Stars
  • 2,491 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 50 Forks
  • 0 Open issues
  • 2 Versions
  • 20 % Grown

The README.md

PHP Selector

Latest Stable Version Total Downloads Build Status, (*1)

A simple DOM query library originally written by tj., (*2)

Installation

composer require bkuhl/php-selector:~1.0

Usage

Given the sample html:, (*3)

$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;

The following will return an array of elements:, (*4)

$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=#]'));

The Versions

13/10 2017

dev-master

9999999-dev

  Sources   Download

MIT

The Development Requires

by Ben Kuhl

13/10 2017

v1.0

1.0.0.0

  Sources   Download

MIT

The Development Requires

by Ben Kuhl