I am getting tr of tables and then in loop i want get text of all td fields, look here:
<?
$lines = $xpath->query("//table[@id='cab_table'] //tr");
var_dump($lines);// Give me object(DOMNodeList)#11 (1) { ["length"]=> int(6) }
for( $i = 0; $i < count($lines); $i++) {
if($i != 0){
$tds = $xpath->query('//td', $lines[$i]);
$result[$i - 1]['number'] = trim($tds->item(0)->nodeValue);
$result[$i - 1]['volume'] = trim($tds->item(1)->nodeValue);
$result[$i - 1]['sum'] = trim($tds->item(2)->nodeValue);
}
}
var_dump($result); //Give me NULL
die();
?>
Why i get NULL?
Now i have:
$lines = $xpath->query("//table[@id='cab_table'] //tr");
foreach($lines as $line) {
$tds = $xpath->query('//td', $line);
$count = $tds->length;
for($i=0; $i<$count; $i++){
echo $tds->item($i)->nodeValue.'<br>';
//echo $i.'<br>';
}
}
But i want make the next for each tr at loop $result[0] = td[0]; $result[1] = td[1]; $result[2] = td[2];
Can you advise me?