有其中由每天更新一天遠程服務器的js array
來源:解析數據,並用簡單的HTML DOM結合
var io = new Array();
nsi[0] = new Array('','Frank','','Factory worker','Mercedes',374.0,26.2,76,181,'',75,'Audi',1456.5,27.1,5 ,183,'',9,19,'','',16,3,4,4,4,3,4,0,4,4,4,2,1,9,1,2,3,2,1,1,4,2,0,0,2,1,2,4,3,4,5,' 3',' 16',55,25,25,55,25,25,3,4,4,4,4,4,4,3,4,3,2,4,2,4,2,3,3,2,2,3,3,3,3,2);
nsi[1] = new Array('','Joseph','','Bank Assistant','Volvo',397,374.0,26.2,76,181,'',75,'BMW',1875.5,27.1,5 ,183,'',9,19,'','',16,3,4,4,4,3,4,0,4,4,4,2,1,9,1,2,3,2,1,1,4,2,0,0,2,1,2,4,3,4,5,' 3',' 16',55,25,25,55,25,25,3,4,4,4,4,4,4,3,4,3,2,4,2,4,2,3,3,2,2,3,3,3,3,2);
nsi[2] = new Array('','Travis','','Shop Assistant','Peugeot',397,374.0,26.2,76,181,'',75,'Ferrari',1866.5,27.1,5 ,183,'',9,19,'','',16,3,4,4,4,3,4,0,4,4,4,2,1,9,1,2,3,2,1,1,4,2,0,0,2,1,2,4,3,4,5,' 3',' 16',55,25,25,55,25,25,3,4,4,4,4,4,4,3,4,3,2,4,2,4,2,3,3,2,2,3,3,3,3,2);
nsi[3] = new Array('','Aaron','','Snow plower','Opel',397,374.0,26.2,76,181,'',75,'Lamborghini',1986.5,27.1,5 ,183,'',9,19,'','',16,3,4,4,4,3,4,0,4,4,4,2,1,9,1,2,3,2,1,1,4,2,0,0,2,1,2,4,3,4,5,' 3',' 16',55,25,25,55,25,25,3,4,4,4,4,4,4,3,4,3,2,4,2,4,2,3,3,2,2,3,3,3,3,2);
我已經做了解析的網站(也使用這個信息js數組)簡單的html dom(它是一個有很多行的簡單表,並且每行都有信息,沒有問題,但我想從這個js數組源中的每一行添加額外的信息)
例如:
row 1: x d s f + the extra informations from the js array nsi[0] nth elements, like Factory worker, 1456
row 2: z 3 e g + the extra informations from the js array nsi[1] nth elements like Bank Assistant, 1875
row 3: 5 6 g s + the extra informations from the js array nsi[2] nth elements like Shop Assistant, 1866
row 4: g b z 3 + the extra informations from the js array nsi[3] nth elements like Snow plower, 1986
這js array
運行在遠程服務器上,但我不知道如何結合簡單的HTML DOM。 (我對js數組非常沒有經驗,如果有人解釋我該如何做到這一點,我應該很開心)。
<?php
include ("mysql.php");
include_once('simple_html_dom.php');
ini_set('display_errors', true);
error_reporting(E_ALL);
$html = file_get_html('source.php');
class persons {
var $day;
var $first_name;
var $last_name;
var $birth_city;
function persons ($day, $first_name, $last_name, $birth_city){
$this->first_name=$first_name;
$this->last_name=$last_name;
$this->birth_city=$birth_city;
return $this;
}
}
$i=0;
$day=$html->find('h3',0);
$day->plaintext;
foreach($html->find('table.workers') as $workers)
{
foreach ($workers->find('tr[class=white],tr[class=grey]') as $workersTR) {
$first_name=$workersTR->find('td[class=a1],td[class=a2]',0)->plaintext;
$last_name=$matchesTR->find('td',1)->plaintext;
$birth_city=$matchesTR->find('td[class=bc]');
$i++;
echo $first_name;
echo $last_name;
echo $birth_city;
}
}
?>
這將有很大的幫助的,你想格式化你的代碼一點,並提供了一些代碼,可以證明你期望的結果 –
我更新了我與完成的代碼問題。我希望有人能幫助我。 – Terminus