$fp = fopen("csvfile.csv", "r");
// read all each of the records and assign to $rec;
while ($rec = fgetcsv($fp)){}
?>
// rec will end up containing the last line
<table>
<tr><td>Name:</td><td><?= $rec[0] ?></td></tr>
<tr><td>Email : </td><td><?= $rec[1] ?></td></tr>
<tr><td>Cell :</td><td> <?= $rec[2] ?></td></tr>
<tr><td>D.O.B :</td><td> <?= $rec[3] ?></td></tr>
</table>
,或者如果你预料到的文件是很长的,你能避免从文件末尾定位文件指针两倍,最高记录长度,然后步行走的每条记录记录集。
$filesize = filesize("csvfile.csv");
$maxRecordLength = 2048;
$fp = fopen("csvfile.csv", "r");
// start near the end of the file and read til the end of the line
fseek($fp, max(0, $filesize - ($maxRecordLength *2));
fgets($fp);
// then do same as above
while ($rec = fgetcsv($fp)){}
?>
<table>
<tr><td>Name:</td><td><?= $rec[0] ?></td></tr>
<tr><td>Email : </td><td><?= $rec[1] ?></td></tr>
<tr><td>Cell :</td><td> <?= $rec[2] ?></td></tr>
<tr><td>D.O.B :</td><td> <?= $rec[3] ?></td></tr>
</table>
fgetcsv的maual页面上的一个例子是一个很好的开始 – 2013-07-10 02:32:45
[你想要的是尾部信息:点击这里](http://stackoverflow.com/a/16999819/1226894) – Baba