[thelist] (no subject)
Burhan Khalid
burhankhalid at members.evolt.org
Tue May 7 17:01:32 CDT 2002
[ snip ]
>I have a text file (flatfile database, basically) with records as follows:
>entry#, place, date, time \n
>I need to find the last entry number in the file.
[ /snip ]
Alright, lets see here. First the steps :
1. Get to the last line of the file
2. Read line.
3. Find first item in line.
Here is the code (I haven't tested it, so be warned) :
#assuming file is opened, and is pointed to by $fp,
if(fseek($fp, -1, SEEK_END)) {
$lastLine = fgets($fp);
$bits = explode("," $lastLine);
$entry = $bits[0];
} else { print "Some error occured!"; }
Again, this *should* work, but I haven't tried it.
hth,
Burhan Khalid
More information about the thelist
mailing list