-First is that it reads only the very first item in the file and just repeats it.
-Second, within the loop I have if going until it reaches 20, but would like the loop to continue until the end of file, but not sure how to do this. Maybe combine both a for and while loop?
Inside the file on each line are 4 separate entries separated by a space to make up one record, then the next row contains a new record and so on.
I've been searching trying to figure this out, but not getting anywhere. I keep reading about using explode instead, but that might be a little down the road right now. This is for an assignment and we are currently studying strtok so I need to stick with it.
Any help is very much appreciated.
Brian
Code: Select all
<?php
include 'file.php';
$token = strtok($filename, " \n");
echo "<table border=\"1\">";
echo '<tr>';
for ($i = 1; $i <= 20; $i++) {
echo "<td>" . $token . "</td>";
if ($i % 4 == 0) {
echo '</tr></tr>';
}
}
echo '</tr>';
echo "</table>";
?>