-5

// 请不要投差票 // // 在这个问题上我需要你的帮助 //

TXT 数据:http ://www.dhmi.gov.tr/UcusBilgileri/2/domarr.txt

我如何定期在我的网站上拥有它?

详情:http: //i.stack.imgur.com/Vb05A.png

注意:对不起我的英语不好

4

1 回答 1

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>
于 2013-07-17T09:49:17.357 回答