|
Posted by Kurt Milligan on 02/08/07 12:44
On Feb 8, 7:31 am, "Ilkka Maatta" <ilkka.maa...@phnet.fi> wrote:
>
> How i can read and print only last row - don't all row?
If you are in a *nix system, you can do:
$lastLine = exec('tail -1 getCodeGetText.php');
Another option, much more memory intensive (for large files), but
works on any system:
$lines = file('/path/to/filename.txt');
$lastLine = $lines[(count($lines) - 1)];
Or, you could loop the lines like you are doing already and just not
print out the lines;
the last line will be the last iteration through the loop.
while (!feof($file))
$line = fgets($fp,1024);
print $line;
HTH
-Kurt
Navigation:
[Reply to this message]
|