開頭的行我正在閱讀一個平面文本文件,通常前幾行是註釋,我怎麼能告訴我腳本忽略它們?忽略以#
腳本的相關部分是:
<?php
$delimiter = chr(1);
$eoldelimiter = chr(2) . "\n";
$fp = fopen('app2','r');
if (!$fp) {echo 'ERROR: Unable to open file.</table></body></html>'; exit;}
$loop = 0;
while (!feof($fp)) {
$loop++;
$line = stream_get_line($fp,4096,$eoldelimiter); //use 2048 if very long lines
$field[$loop] = explode ($delimiter, $line);
echo '
<tr>
<td>'.$field[$loop][0].'</td>
<td>'.$field[$loop][1].'</td>
<td>'.$field[$loop][2].'</td>
<td>'.$field[$loop][3].'</td>
<td>'.$field[$loop][4].'</td>
<td>'.$field[$loop][5].'</td>
<td>'.$field[$loop][6].'</td>
<td>'.$field[$loop][7].'</td>
<td>'.$field[$loop][8].'</td>
<td>'.$field[$loop][9].'</td>
<td>'.$field[$loop][10].'</td>
<td>'.$field[$loop][11].'</td>
<td>'.$field[$loop][12].'</td>
<td>'.$field[$loop][13].'</td>
<td>'.$field[$loop][14].'</td>
<td>'.$field[$loop][15].'</td>
<td>'.$field[$loop][16].'</td>
</tr>';
$fp++;
}
fclose($fp);
?>
文件看起來是這樣的:
#export_dateapplication_idtitlerecommended_ageartist_nameseller_namecompany_urlsupport_urlview_urlartwork_url_largeartwork_url_smallitunes_release_datecopyrightdescriptionversionitunes_versiondownload_size
#primaryKey:application_id
#dbTypes:BIGINTINTEGERVARCHAR(1000)VARCHAR(20)VARCHAR(1000)VARCHAR(1000)VARCHAR(1000)VARCHAR(1000)VARCHAR(1000)VARCHAR(1000)VARCHAR(1000)DATETIMEVARCHAR(4000)LONGTEXTVARCHAR(100)VARCHAR(100)BIGINT
#exportMode:FULL
1276678802857300728328Shanghai Pudong Miracle4+iJour Inc.Stanley Huanghttp://www.ijour.com.cn/http://www.ijour.com.cn/http://test.com/app/shanghai-pudong-miracle/id300728328?uo=5http://
謝謝你的完美工作 – kitenski 2010-07-16 13:20:12