Query Eq - ThomasWeinert/FluentDOM GitHub Wiki
FluentDOM\Query eq(int $position);
Reduce the set of matched elements to a single element.
$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');
<!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>