Read Last Line
Posted: Thu Jun 07, 2007 10:33 am
Is there an faster way of reading the last line in a file ?
I want try avoiding going through a list of lines if the data is very huge.
I know the solution for indexing is database, but Im looking for something fast enough like unix's tail -1.
I want try avoiding going through a list of lines if the data is very huge.
Code: Select all
$csvName = "csv-file.csv";
$fh = @fopen($csvName, "r") or die("Couldnt open file for reading");
while (($data = fgetcsv($fh, 10000, ",")))
{
$LastIndex = $data[0];
}
echo $LastIndex;
@fclose($fh);