我使用phpQuery從元素中獲取數據。從每個td獲取值
我試圖從第一個td
,秒td
和href
鏈接從每個tr
鏈接的值。
<table>
<tr class="A2">
<td> Text 1 </td>
<td> Text 2 </td>
<td> Text 3 </td>
<td> <a href="linkhere1"> Text 131</a> </td>
</tr>
<tr class="A2">
<td> Text 4 </td>
<td> Text 5 </td>
<td> Text 6 </td>
<td> <a href="linkhere2"> Text 123213</a> </td>
</tr>
<tr class="A2">
<td> Text 7 </td>
<td> Text 8 </td>
<td> Text 9 </td>
<td> <a href="linkhere3.php"> Text 213213 </a> </td>
</tr>
</table>
如何做到這一點?我曾嘗試:
<?
require('phpQuery.php');
$file = file_get_contents('test.txt', true);
$html = phpQuery::newDocument($file);
foreach($html->find('.A2') as $tag) {
echo pq('td'); // problem here?
}
?>
pq()來自哪裏 – Ibu 2011-05-13 15:35:07