Reputation: 13
I have a txt file containing some temperatures:
26 C
25.06 C
25.00 C
25.00 C
25.00 C
25.00 C
24.94 C
24.94 C
24.94 C
24.94 C
24.94 C
24.94 C
And I want those lines to be echo out in a table in my php/html file:
<table>
<tr>
<th>Date</th>
<th>Time</th>
<th>TEMP</th>
</tr>
<tr>
<td>Date</td>
<td>Time</td>
<td>TEMP</td>
</tr>
</table>
How I do this?
Upvotes: 0
Views: 137
Reputation: 41081
You didn't provide any example data for how you get the Date and Time, but given your temps.txt
<table>
<thead>
<tr>
<th>Date</th>
<th>Time</th>
<th>TEMP</th>
</tr>
</thead>
<tbody>
<?php
foreach (file('temps.txt') as $temp) {
echo "
<tr>
<td>Date</td>
<td>Time</td>
<td>$temp</td>
</tr>
";
}
?>
</tbody>
</table>
If your file also contains date/time information, then you might be interested in using a CSV format with fgetcsv
Upvotes: 1