您好我想解析一个 HTML 表并将这些值分配给 php 变量,以便我可以将它们插入到 mysql 数据库中
我尝试了一些 html 解析方法,例如 dom_html_parsing,但是作为初学者,我感到很困惑,如果有人对此提供一些提示以便我可以编码,我会很高兴
我使用的解析代码是
include('simple_html_dom.php');
$dom = str_get_html($result);
$table = array();
$html = str_get_html($result);
foreach($html->find('tr') as $row) {
$time = $row->find('td',-1)->plaintext;
$title = $row->find('td',0)->plaintext;
$title0 = $row->find('td',1)->plaintext;
$title1 = $row->find('td',2)->plaintext;
$title2 = $row->find('td',3)->plaintext;
$title3 = $row->find('td',4)->plaintext;
$title4 = $row->find('td',5)->plaintext;
$title5 = $row->find('td',6)->plaintext;
$table[$title][$title0][$title1][$title2][$title3][$title4][$title3] = true;
}
echo '<pre>';
print_r($table);
echo '</pre>';
数组正在打印,但我不知道如何将这些特定值插入到 mysql 数据库中,我想先将这些值分配给变量,以便我可以插入到数据库中,我需要的格式如上所示,名称和父亲名& htno 在 html 表格中只打印一次,但我需要在表格的每一行重复它
请帮我