我正在解析HTML。所以我需要以这种方式从网站获取数据: 日期 - 时间 - 价格 - 可用 所以我有代码:
$content = file_get_html('http://lovushka-quest.ru/quest/137');
$data = array();
//getting date
foreach ($content->find('.myDay') as $questday) {
$qdate = $questday->find('.d', 0) . " " . $questday->find('.m', 0);
}
//getting time and price during one day
foreach ($content->find('.qwestRimesLine') as $line ) {
//??
foreach ($line->find('.timeItem') as $item) {
//getting data
$string = strpos(htmlspecialchars($li->outertext), 'off');
$available = '';
if($string != false) $available = 'disabled';
$vars = explode(" ", trim($item->plaintext));
//array with my data
$tmp = array();
$tmp[$qdate] = array('price' => $vars[0], 'time' => $vars[1], 'available' => $available);
$data[] = $tmp;
unset($tmp);
}
}
这不正确,因为我不知道如何同步日期循环和数据循环 提前谢谢!