1<?php
2$inputfile = file("prod.txt");
3
4$data_lines = array();
5foreach ($inputfile as $line)
6{
7 $data_lines[] = explode(";", $line);
8}
9
10//Get column headers.
11$first_line = array();
12foreach ($data_lines[0] as $dl)
13{
14 $first_line[] = explode("=", $dl);
15}
16$headers = array();
17foreach ($first_line as $fl)
18{
19 $headers[] = $fl[0];
20}
21
22// Get row content.
23$data_cells = array();
24for ($i = 0; $i < count($data_lines); $i++)
25{
26 $data_cell = array();
27 for ($j = 0; $j < count($headers); $j++)
28 {
29 $data_cell[$j] = substr($data_lines[$i][$j], strpos($data_lines[$i][$j], "=")+1);
30 }
31 $data_cells[$i] = $data_cell;
32 unset($data_cell);
33}
34?>
35<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
36<html>
37 <head>
38 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
39 <title>HTML Table With PHP</title>
40 </head>
41 <body>
42 <table border="1">
43 <tr>
44 <?php foreach ($headers as $header): ?>
45 <th><?php echo $header; ?></th>
46 <?php endforeach; ?>
47 </tr>
48 <?php foreach ($data_cells as $data_cell): ?>
49 <tr>
50 <?php for ($k = 0; $k < count($headers); $k++): ?>
51 <td><?php echo $data_cell[$k]; ?></td>
52 <?php endfor; ?>
53 </tr>
54 <?php endforeach; ?>
55 </table>
56 </body>
57</html>
58