이 코드 get table.첫 번째 또는 특정 하위 노드 xpath를 제거합니다.
테이블에서 첫 번째 및 두 번째 tr 태그를 제거하고 싶습니다. 벨로우즈 테이블 TR 2
$data = array();
$table_rows = $xpath->query('//table[@class="adminlist"]/tr');
if($table_rows->length <= 0) { // exit if not found
echo 'no table rows found';
exit;
}
foreach($table_rows as $tr) { // foreach row
$row = $tr->childNodes;
if($row->item(0)->tagName != 'tblhead') { // avoid headers
$data[] = array(
'Name' =>trim($row->item(0)->nodeValue),
'LivePrice' => trim($row->item(2)->nodeValue),
'Change'=> trim($row->item(4)->nodeValue),
'Lowest'=> trim($row->item(6)->nodeValue),
'Topest'=> trim($row->item(8)->nodeValue),
'Time'=> trim($row->item(10)->nodeValue),
);
}
}
및 질문은 두 개의 클래스 --- EvenRow_Print 및 OddRow_Print --- 내가 한 2 차원 배열의 두 TR 에코 어떻게
$data = array();
$table_rows = $xpath->query('//table/tr');
if($table_rows->length <= 0) {
echo 'no table rows found';
exit;
}
foreach($table_rows as $tr) { // foreach row
$row = $tr->childNodes;
if($row->item(0)->tagName != 'tblhead') { // avoid headers
$data[] = array(
'Name' =>trim($row->item(0)->nodeValue),
'LivePrice' => trim($row->item(2)->nodeValue),
'Change'=> trim($row->item(4)->nodeValue),
'Lowest'=> trim($row->item(6)->nodeValue),
'Topest'=> trim($row->item(8)->nodeValue),
'Time'=> trim($row->item(10)->nodeValue),
);
}
}
있습니다. examp.
Array(
[0] => Array(
//array
)
}
감사의
질문 당 하나의 질문 만하십시오. 한 번에 두 가지 질문을하는 것은 Stackoverflow에서 작동하지 않습니다. – hakre