You are here: Re: How read ONLY last row ASCII file « PHP Programming Language « IT news, forums, messages
Re: How read ONLY last row ASCII file

Posted by SquishedOrange on 02/08/07 20:51

Ur guys,

Have we read http://uk.php.net/manual/en/function.fseek.php ?

If you read the comments, there are some nice functions there

This one looks good:
<?php
function readLastLine ($file) {
$fp = @fopen($file, "r");

$pos = -1;
$t = " ";
while ($t != "\n") {
if (!fseek($fp, $pos, SEEK_END)) {
$t = fgetc($fp);
$pos = $pos - 1;
} else {
rewind($fp);
break;
}
}
$t = fgets($fp);
fclose($fp);
return $t;
}
?>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация