Skip to content
Thomas Weinert edited this page Jul 30, 2014 · 1 revision

FluentDOM\Query::eq()

FluentDOM\Query eq(int $position);

Reduce the set of matched elements to a single element.

Usage

$html = <<<HTML
<html>
  <head>
    <title>Examples: FluentDOM\Query::eq()</title>
  </head>
  <body>
    <div/>
    <div/>
    <div/>
    <div/>
    <div/>
    <div/>
  </body>
</html>
HTML;

echo FluentDOM($html, 'text/html')
  ->find('//div')
  ->eq(2)
  ->addClass('emphased');

Output

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html><head><title>Examples: FluentDOM\Query::eq()</title></head><body>
    <div></div>
    <div></div>
    <div class="emphased"></div>
    <div></div>
    <div></div>
    <div></div>
  </body></html>
Clone this wiki locally