Return to Snippet

Revision: 20555
at November 18, 2009 15:26 by Knarf


Initial Code
<?php

$file=file_get_contents("textfile.txt");
$file_splited = preg_split("/\n/", $file);

$table = "<table>\n";
foreach($file_splited as $itemname => $item) {
    $table .= "<tr> <td> " . $itemname . " </td> <td> " . $item . " </td> </tr>\n";
}
$table .= "</table>\n\n";

echo $table;
?>

Initial URL

                                

Initial Description
A script I used for quickly load a file (see line 3) and then make a table which had linenumbers on each line. You may want to add a +1 when its generating the table...

Initial Title
Quickly load a file and give each line a linenumber.

Initial Tags
table, array

Initial Language
PHP