0
어떻게 끝에서 주문에 따라 요소를 얻을 수 있습니까?PHPQuery로 끝에서 요소를 얻는 방법?
예를 들어 끝에서 두 번째 항목을 가져와야합니다.
<?php
$html = <<<EOD
<div style="text-align: center;" class="navigation">
<span class="pagination">
<span>« novější</span> |
<span>1</span> |
<a href="?listType=&sort=&page=1">2</a> |
<a href="?listType=&sort=&page=2">3</a> |
<a href="?listType=&sort=&page=3">4</a> |
<a href="?listType=&sort=&page=1">starší »</a>
</span>
</div>
EOD;
$dom = PHPQuery::newDocument($html);
var_dump($dom->find('.navigation > .pagination > *')->eq(-2)->text());
var_dump($dom->find('.navigation > .pagination > *:last-child(2)')->text());
하지만 그 대신 4의 코드는 반환
string(0) ""
string(11) "starší »"
이'출력으로 starší' 하시겠습니까? –
왜 : $ dom-> find ('. navigation> .pagination> * : eq (-2)') -> text()? jQuery에서는 last-child (2)가 PHPQuery에서 인수를 사용합니까? 마지막 사례 인 "star"가 반환됩니다. – Picard