Friday, August 1, 2014

Display Text File in Multiple Columns

<?php
$filename = "path_to_file.txt"; // your text file
$lines = file($filename);
echo '<table border="0" width="100%"><tr>';
for($i=0; $i<sizeof($lines); $i++) {
$info = explode(":",$lines[$i]); // change to what you use to separate columns
    echo '<td>' .$info[0]. '</td>';
    if(($i+1)%3==0 && $i!=sizeof($lines)-1) echo '</tr><tr>'; // change the 3 to the number of columns
}
echo '</tr></table>';
?>

No comments:

Post a Comment