I need some help getting started in writing the php code that would import a text file of name/value pairs and then create an html table with those values.
The datafile looks something like this: [number]-[attribute]=[value];
1-Host=server1.abc.dev.jkl;2-Date=Wed Aug 12 2010;3-Set=abc.123.cde;4-Time=01:00:03;5-Length=00:36:09;6-Size=41.54 GB;7-Status=Succeeded;
1-Host=server2.abc.dev.qrs;2-Date=Wed Aug 12 2010;3-Set=gls202.kul_lvm;5-Length=06:20:33;7-Status=Succeeded;
1-Host=server9.mra.dev.xyz;2-Date=Wed Aug 11 2010;3-Set=gls101.aie_lvm;4-Time=01:00:02;
Let's say I have an html table:
<table id="stats">
tr>
<th>Host</th>
<th>Date</th>
<th>Set</th>
<th>Time</th>
<th>Length</th>
<th>Size</th>
<th>Status</th>
</tr>
<tr>
<td>server1.abc.dev.jkl</td>
<td>Wed Aug 12 2010</td>
<td>abc.123.cde</td>
<td>01:00:03</td>
<td>00:36:09</td>
<td>41.54 GB</td>
<td>Succeeded</td>
</tr>
</table>
I've looked around all day at various samples. I've seen the fgetcsv function. I'm not sure what would be the best approach to load this into data into a table. Using a regex, then load into array or hash and then print this out? I'm assuming i would have to create print statements to produce the html tags.
Also, with the sample records I provided. There will be instances where not all the attributes (1-7) have values.
So, i'm envisioning empty cells for that record which is fine.
I can also change the way the datafile is generated and remove the [number], so its just [attribute]=[value] if that makes it easier.
Is there a good mapping technique for this? Thank you for your help.