[Solved] TXT to publish the data in the table [closed]


If you want to read the text file and split the values to columns in a table try this:

<?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>

8

solved TXT to publish the data in the table [closed]