$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