//请不要给出错误的投票// //我在这个问题上需要你的帮助//
TXT数据:http://www.dhmi.gov.tr/UcusBilgileri/2/domarr.txt
我如何定期在我的网站上拥有它?
详细信息:http://i.stack.imgur.com/Vb05A.png
注意:我很抱歉我的英语不好
答案 0 :(得分:1)
如果要读取文本文件并将值拆分为表格中的列,请尝试:
<?php
$handle = @fopen("domarr.txt", "r");
while (!feof($handle))
{
$buffer = fgets($handle, 4096);
if (strlen(trim($buffer)) > 0){
list($a,$b,$c,$d,$e,$f,$g,$h,$i,$j)=explode(",",$buffer);
$items[] = array('col1' => $a,'col2' => $b,'col3' => $c,'col4' => $d,'col5' => $e,'col6' => $f,'col7' => $g,'col8' => $h,'col9' => $i,'col10' => $j);
}
}
?>
<table>
<thead>
<tr>
<th>Col 1</th>
<th>Col 2</th>
<th>Col 3</th>
<th>Col 4</th>
<th>Col 5</th>
<th>Col 6</th>
<th>Col 7</th>
<th>Col 8</th>
<th>Col 9</th>
<th>Col 10</th>
</tr>
</thead>
<tbody>
<?php foreach($items as $value) { ?>
<tr>
<td><?= $value['col1'] ?></td>
<td><?= $value['col2'] ?></td>
<td><?= $value['col3'] ?></td>
<td><?= $value['col4'] ?></td>
<td><?= $value['col5'] ?></td>
<td><?= $value['col6'] ?></td>
<td><?= $value['col7'] ?></td>
<td><?= $value['col8'] ?></td>
<td><?= $value['col9'] ?></td>
<td><?= $value['col10'] ?></td>
</tr>
<?php } ?>
</tbody>
</table>