我試着檢索電子郵件地址,有些ID的人沒有一個電子郵件地址,因此不具備$ gp_rowDOM XPath查詢返回沒有
當我的var_dump的$ gprow我只接收字符串( x)的電子郵件地址,目的是做一個CSV文件,有沒有辦法只返回一個逗號,如果它不能從路徑返回字符串?
在此先感謝
<?php
$count = 0;
while($count <= 3) {
$emails = array(508561, 521174, 470245, 535282);
$html = file_get_contents('http://xxxxxxxxxx.xxxx/office/'. $emails[$count] .'');
$gp_doc = new DOMDocument();
libxml_use_internal_errors(TRUE); //disable libxml errors
$gp_xpath = new DOMXPath($gp_doc);
$gp_row = $gp_xpath->query('//dd[6]/a');
foreach($gp_row as $row){
$file = '1.csv';
$current = file_get_contents($file);
$current .= $row->nodeValue . ", ";
$trimmed = ltrim($current, ",");
file_put_contents($file, $trimmed);
}
$count++;
}
?>
沒有改變任何東西 – Bill
@Bill你能分享你的'print_r($ html)'嗎? –