Javascript / PHP,使用文本文件作为数据库,并将内容组织到一个阵列表中

I'm trying to find the easiest way to do this. (PHP or Javascript) Basically, I have a text file that looks like this:

1
的
de/dí /dì 
(possessive particle)/of, really and truly, aim/clear
2
一
yī 
one/1/single/a(n)
3
是
shì 
is/are/am/yes/to be
4
不
bù /bú 
(negative prefix)/not/no
5
了
le/liǎo /liào 
(modal particle intensifying preceding clause)/(completed action marker), to know/to understand/to know, clear, look afar from a high place

I want to read the data and insert it into a table such as:

<table cellpadding="0" cellspacing="0" border="1">
    <tr>
      <td width="50" height="50" align="center">1</td>
      <td width="50" height="50" align="center" >的</td>
      <td width="50" height="50" align="center">de/dí /dì</td>
        <td width="50" height="50" align="center">(possessive particle)/of, really and truly, aim/clear</td>

    </tr>
        <tr>
      <td width="50" height="50" align="center">2</td>
      <td width="50" height="50" align="center">一</td>
      <td width="50" height="50" align="center">yī </td>
        <td width="50" height="50" align="center">one/1/single/a(n)</td>
    </tr>
</table>

I suppose there are two ways to do this. The first is organizing the content into variables (1a, 1b, 1c, 1d, 2a, 2b, 2c, 2d...) and then find some way to with minimal effort to insert the variables into a set number of tables.

The second way is to organize the data in an array, then array the data to generate a table. I think this may be the best way, but I need to be able to specify which portion of the table (like page 1 (entries 1-100), etc.

If each data set in the file always consists of 4 rows, this is how you can generate the table rows:

<?php
$rows=file('path/to/file.txt');
$start=1;
$max=100;
echo '<tr>';
for($length=count($rows); $start<=$length && $start<=$max; $start++){
    echo '<td>',$rows[$start-1],'</td>';
    if($start %4 == 0) echo '</tr><tr>';
}
echo '</tr>';
?>

Then you just have to build the rest of the table around it. Set the formatting (like heights) in a CSS file. To show only part of data, just set the $start and $max variables accordingly. I've kept it short for brevity. Obviously, add checks like if the file isn't actually empty and so on...

Assuming there are always 4 lines per entry, start by reading the file into an array where each value is a single line. Then create a loop that iterates every 4 lines (i = i + 4), and within the body of the loop, access each element relative to the current iteration (line[i], line[i+1], line[i+2], line[i+3]).

Alternatively, you could use a JSON array to store your data in a file, where each value is it's own object containing each entry as it's own key. Both PHP and JavaScript have native support for reading and writing JSON. Then you could just loop through the resulting array and point to the keys you need.