我正在使用simplehtmldom解析網頁並提取數據,然後將其放入mysql數據庫中。我成功地提取了數據並將其放入數組中,但現在我面臨的問題是如何將此數組轉換爲變量,以便我可以在數據庫查詢中將它用於在特定字段中插入記錄。我想數組轉換爲單個變量將數組轉換爲單個變量
這裏是代碼
<?php
include("simple_html_dom.php");
$html = file_get_html('abc.html');
$sched = array();
foreach ($html->find('tr[class=highlight-darkgrey]') as $event) {
$item['title'] = trim($event->find('td', 1)->plaintext);
$sched[] = $item;
}
var_dump($sched);
?>
和輸出
array (size=6)
0 =>
array (size=1)
'title' => string 'Network admin, field engineer, engineering analyst, sales executive, PA to HR director Required by Telecommunication Company' (length=124)
1 =>
array (size=1)
'title' => string 'Karachi, Hydrabad, Lahore, Rawalpindi, Peshawar, Multan, Faisalabad' (length=67)
2 =>
array (size=1)
'title' => string '5 - 6 Years' (length=11)
3 =>
array (size=1)
'title' => string 'Knowledge of Field' (length=18)
4 =>
array (size=1)
'title' => string '' (length=0)
5 =>
array (size=1)
'title' => string '- Salary and incentives are not full and final. Can be discussed on final interview.
可以請人可以幫我實現它。在此先感謝
你真正擁有的是一個數組的數組。我不明白你的問題是什麼,因爲你顯然已經知道如何使用foreach結構。也許你可以展示一些你已經嘗試過的代碼,而這些代碼並不是你想做的。 –